From 7b9ea430b434c0064c73511afdf6697c382f2361 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Sat, 12 Oct 2024 13:37:32 -0700 Subject: [PATCH 1/2] CU-868a7t5eb Fixed upcoming calendar item ordering issue. --- .../Controllers/v4/CalendarController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs b/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs index 789e6aaf..9d512f61 100644 --- a/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs +++ b/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs @@ -109,7 +109,7 @@ public async Task> GetDepartmentCalendarI if (items != null && items.Any()) { - + items = items.OrderBy(x => x.Start).ToList(); foreach (var item in items) { if (item.ItemType > 0) From 6450fbe18d5b7f066354806b235bb323485b0eda Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Wed, 11 Dec 2024 22:03:48 -0800 Subject: [PATCH 2/2] CU-868ba84kp Postgres migration work --- Core/Resgrid.Config/DataConfig.cs | 29 + Core/Resgrid.Config/OidcConfig.cs | 5 + Core/Resgrid.Config/WorkerConfig.cs | 5 + Core/Resgrid.Model/MapLayer.cs | 24 + Core/Resgrid.Model/PersonnelLocation.cs | 11 + .../Repositories/IMapLayersRepository.cs | 14 + .../Repositories/IOidcRepository.cs | 6 +- .../IPersonnelLocationsDocRepository.cs | 15 + .../IUnitLocationsDocRepository.cs | 15 + Core/Resgrid.Model/UnitsLocation.cs | 11 + Core/Resgrid.Services/MappingService.cs | 54 +- .../Migrations/M0001_InitialMigrationPg.cs | 18 + .../Migrations/M0002_AddingContacts.cs | 39 + .../Migrations/M0003_AddingUnitActiveRoles.cs | 33 + .../Migrations/M0004_AddingSortToTemplates.cs | 18 + .../Migrations/M0005_AddingForms.cs | 48 + .../Migrations/M0006_AddingFormDataToCalls.cs | 20 + .../M0007_AddingDispatchOnToCalls.cs | 20 + .../Migrations/M0008_AddingAddonsInvoices.cs | 62 + .../Migrations/M0009_AddingDepartmentVoice.cs | 56 + .../Migrations/M0010_AddingSystemAudits.cs | 30 + .../Migrations/M0011_AddingAutofills.cs | 27 + .../Migrations/M0012_UpdatingUnitCallTypes.cs | 20 + .../Migrations/M0013_UpdatingLinkedCall.cs | 19 + .../Migrations/M0014_AddingWorkshifts.cs | 73 + .../M0015_AddingMissingWorkshiftValues.cs | 20 + .../Migrations/M0016_AddingUnifiedPlan.cs | 19 + .../Migrations/M0017_AddingToAuditTable.cs | 23 + .../M0018_AddingToCallNotesAndFiles.cs | 37 + .../M0019_AddingDeleteReasonToCalls.cs | 20 + .../M0020_AddingLangToUPAndSystemQ.cs | 26 + .../Migrations/M0021_AddingCallReferences.cs | 33 + .../M0022_AddingQuantityForPlanAddon.cs | 19 + .../M0023_AddingPlanAddonFor10Pack.cs | 26 + .../Migrations/M0024_AddingDepartmentAudio.cs | 30 + .../M0025_AddingTypeToDepartmentAudio.cs | 19 + .../Migrations/M0026_AddingEntityPlan.cs | 30 + .../M0027_AddingFreeEntityLimits.cs | 19 + .../M0028_AddingDeletedWorkshiftColumns.cs | 20 + .../M0029_AddingCustomStateDetailColumns.cs | 20 + .../M0030_AddingDocumentCategories.cs | 28 + .../Migrations/M0031_AddingNoteCategories.cs | 28 + .../Resgrid.Providers.MigrationsPg.csproj | 32 + .../Sql/EF0001_PopulateOIDCDb.sql | 343 ++++ .../Sql/EF0003_PopulateDocDb.sql | 52 + .../Sql/M0001_InitialMigration.sql | Bin 0 -> 278484 bytes .../ActionLogsRepository.cs | 22 +- .../CalendarItemAttendeeRepository.cs | 2 +- .../CalendarItemsRepository.cs | 10 +- .../CallAttachmentRepository.cs | 4 +- .../CallDispatchGroupRepository.cs | 4 +- .../CallDispatchRoleRepository.cs | 2 +- .../CallDispatchUnitRepository.cs | 2 +- .../CallDispatchesRepository.cs | 4 +- .../CallLogsRepository.cs | 4 +- .../CallNotesRepository.cs | 2 +- .../CallProtocolsRepository.cs | 2 +- .../CallReferencesRepository.cs | 4 +- .../CallsRepository.cs | 18 +- .../Configs/SqlConfiguration.cs | 1 + .../CustomStateRepository.cs | 4 +- .../DepartmentCallPruningRepository.cs | 2 +- .../DepartmentGroupMembersRepository.cs | 8 +- .../DepartmentGroupsRepository.cs | 10 +- .../DepartmentLinksRepository.cs | 4 +- .../DepartmentMembersRepository.cs | 10 +- .../DepartmentSettingsRepository.cs | 10 +- .../DepartmentVoiceChannelRepository.cs | 4 +- .../DepartmentVoiceRepository.cs | 2 +- .../DepartmentVoiceUserRepository.cs | 2 +- .../DepartmentsRepository.cs | 16 +- .../DispatchProtocolAttachmentRepository.cs | 2 +- .../DispatchProtocolQuestionsRepository.cs | 2 +- .../DispatchProtocolRepository.cs | 4 +- .../DispatchProtocolTriggersRepository.cs | 2 +- .../DistributionListMemberRepository.cs | 4 +- .../DistributionListRepository.cs | 8 +- .../Extensions/CitextParameter.cs | 27 + .../Extensions/ColumnsBuilderExtensions.cs | 6 + .../Extensions/DynamicParametersExtension.cs | 37 + .../SqlQueryParametersExtensions.cs | 9 +- .../Extensions/StringReplaceExtensions.cs | 82 +- .../FormAutomationsRepository.cs | 2 +- .../FormsRepository.cs | 10 +- .../IdentityRepository.cs | 403 +++-- .../IdentityRoleRepository.cs | 10 +- .../IdentityUserRepository.cs | 8 +- .../InventoryRepository.cs | 8 +- .../InvitesRepository.cs | 4 +- .../LogAttachmentRepository.cs | 2 +- .../LogUnitsRepository.cs | 2 +- .../LogUsersRepository.cs | 4 +- .../LogsRepository.cs | 12 +- .../MessageRecipientRepository.cs | 4 +- .../MessageRepository.cs | 18 +- .../Modules/ApiDataModule.cs | 15 +- .../Modules/DataModule.cs | 15 +- .../Modules/NonWebDataModule.cs | 15 +- .../Modules/TestingDataModule.cs | 15 +- .../NotesRepository.cs | 2 +- .../OidcRepository.cs | 89 +- .../PaymentRepository.cs | 8 +- .../PermissionsRepository.cs | 2 +- .../PersonnelCertificationRepository.cs | 2 +- .../PersonnelRoleUsersRepository.cs | 6 +- .../PersonnelRolesRepository.cs | 8 +- .../PlansRepository.cs | 2 +- .../PoiTypesRepository.cs | 4 +- .../ActionLogs/SelectALogsByDateRangeQuery.cs | 2 +- .../ActionLogs/SelectALogsByDidQuery.cs | 2 +- .../SelectALogsByUserInDateRangQuery.cs | 2 +- .../SelectActionLogsByCallIdQuery.cs | 2 +- .../SelectActionLogsByCallIdTypeQuery.cs | 2 +- .../SelectActionLogsByUserIdQuery.cs | 2 +- .../SelectLastActionLogByUserIdQuery.cs | 2 +- .../SelectLastActionLogForUserQuery.cs | 2 +- .../SelectLastActionLogsForDepartmentQuery.cs | 2 +- .../SelectPerviousActionLogsByUserQuery.cs | 2 +- .../Calendar/DeleteCalendarItemQuery.cs | 2 +- .../SelectCalendarItemAttendeeByUserQuery.cs | 2 +- .../Calendar/SelectCalendarItemByDIdQuery.cs | 2 +- .../Calendar/SelectCalendarItemByIdQuery.cs | 2 +- .../SelectCalendarItemsByDateQuery.cs | 2 +- .../SelectCalendarItemsByRecurrenceIdQuery.cs | 2 +- .../SelectAllCallDispatchesByCallIdQuery.cs | 2 +- .../SelectAllCallDispatchesByGroupIdQuery.cs | 2 +- .../SelectAllCallGroupDispsByCallIdQuery.cs | 2 +- ...ectAllCallReferencesBySourceCallIdQuery.cs | 2 +- ...ectAllCallReferencesByTargetCallIdQuery.cs | 2 +- .../SelectAllCallRoleDispsByCallIdQuery.cs | 2 +- .../SelectAllCallUnitDispsByCallIdQuery.cs | 2 +- .../Calls/SelectAllCallsByDidDateQuery.cs | 2 +- .../Calls/SelectAllCallsByDidLoggedOnQuery.cs | 2 +- .../SelectAllClosedCallsByDidDateQuery.cs | 2 +- .../SelectAllClosedCallsByDidYearQuery.cs | 2 +- .../Calls/SelectAllOpenCallsByDidDateQuery.cs | 2 +- .../SelectCallAttachmentByCallIdQuery.cs | 2 +- .../SelectCallAttachmentByCallIdTypeQuery.cs | 2 +- .../Calls/SelectCallNotesByCallIdQuery.cs | 2 +- .../Calls/SelectCallProtocolsByCallIdQuery.cs | 2 +- .../Calls/SelectCallYearsByDeptQuery.cs | 2 +- ...tNonDispatchedScheduledCallsByDateQuery.cs | 2 +- ...ctNonDispatchedScheduledCallsByDidQuery.cs | 2 +- .../Calls/UpdateUserDispatchesAsSentQuery.cs | 2 +- .../Certifications/SelectCertsByUserQuery.cs | 2 +- .../Queries/Common/DeleteMultipleQuery.cs | 2 +- .../Queries/Common/DeleteQuery.cs | 4 +- .../Queries/Common/InsertQuery.cs | 2 +- .../Queries/Common/SelectAllQuery.cs | 2 +- .../Common/SelectByDepartmentIdQuery.cs | 2 +- .../Queries/Common/SelectByIdQuery.cs | 2 +- .../Queries/Common/SelectByUserIdQuery.cs | 2 +- .../Queries/Common/UpdateQuery.cs | 2 +- .../SelectStatesByDidUserQuery.cs | 2 +- .../CustomStates/SelectStatesByIdQuery.cs | 2 +- .../DeleteGroupMembersByGroupIdDidQuery.cs | 2 +- .../SelectAllGroupsByDidQuery.cs | 2 +- .../SelectAllGroupsByParentIdQuery.cs | 2 +- .../SelectGroupAdminsByDidQuery.cs | 2 +- .../SelectGroupByDispatchCodeQuery.cs | 2 +- .../SelectGroupByGroupIdQuery.cs | 2 +- .../SelectGroupByMessageCodeQuery.cs | 2 +- .../SelectGroupMembersByGroupIdQuery.cs | 7 +- .../SelectGroupMembersByUserDidQuery.cs | 2 +- .../SelectAllLinkForDepartmentIdQuery.cs | 2 +- .../SelectAllLinksForDepartmentQuery.cs | 2 +- .../SelectMembersByDidUserIdQuery.cs | 2 +- .../SelectMembersByUserIdQuery.cs | 2 +- .../SelectMembersUnlimitedInclDelQuery.cs | 2 +- .../SelectMembersUnlimitedQuery.cs | 2 +- .../SelectMembersWithinLimitsQuery.cs | 2 +- .../SelectAllManagerInfoQuery.cs | 21 +- .../SelectBySettingAndTypeQuery.cs | 2 +- .../SelectBySettingTypeDepartmentIdQuery.cs | 2 +- .../SelectBySettingTypeUserIdQuery.cs | 23 +- .../SelectManagerInfoByEmailQuery.cs | 23 +- .../SelectCallPruningByDidQuery.cs | 2 +- .../Departments/SelectDepartmentByIdQuery.cs | 2 +- .../SelectDepartmentByLinkCodeQuery.cs | 2 +- .../SelectDepartmentByNameQuery.cs | 2 +- .../SelectDepartmentByUserIdQuery.cs | 2 +- .../SelectDepartmentByUsernameQuery.cs | 2 +- .../SelectDepartmentReportByDidQuery.cs | 2 +- .../SelectDepartmentStatsByUserDidQuery.cs | 2 +- .../SelectValidDepartmentByUsernameQuery.cs | 2 +- .../SelectAllEnabledDListsQuery.cs | 2 +- .../SelectDListByEmailQuery.cs | 2 +- .../DistributionLists/SelectDListByIdQuery.cs | 2 +- .../SelectDListMembersByListIdQuery.cs | 2 +- .../SelectDListMembersByUserQuery.cs | 2 +- .../SelectDListsByDIdQuery.cs | 2 +- .../SelectFormAutomationsByFormIdQuery.cs | 2 +- .../Queries/Forms/SelectFormByIdQuery.cs | 2 +- .../Queries/Forms/SelectFormsByDIdQuery.cs | 2 +- .../Forms/SelectNonDeletedFormsByDIdQuery.cs | 2 +- .../Forms/UpdateFormsToDisableQuery.cs | 2 +- .../Queries/Forms/UpdateFormsToEnableQuery.cs | 2 +- .../Identity/Role/DeleteRoleClaimQuery.cs | 2 +- .../Queries/Identity/Role/DeleteRoleQuery.cs | 2 +- .../Identity/Role/GetClaimsByRoleQuery.cs | 2 +- .../Queries/Identity/Role/InsertClaimQuery.cs | 2 +- .../Queries/Identity/Role/InsertRoleQuery.cs | 2 +- .../Identity/Role/SelectRoleByIdQuery.cs | 2 +- .../Identity/Role/SelectRoleByNameQuery.cs | 2 +- .../Queries/Identity/Role/UpdateRoleQuery.cs | 2 +- .../Queries/Identity/User/DeleteUserQuery.cs | 2 +- .../Identity/User/GetClaimsByUserIdQuery.cs | 2 +- .../Identity/User/GetRolesByUserIdQuery.cs | 2 +- ...LoginByLoginProviderAndProviderKeyQuery.cs | 2 +- .../User/GetUserLoginInfoByIdQuery.cs | 2 +- .../Identity/User/GetUsersByClaimQuery.cs | 2 +- .../Identity/User/GetUsersInRoleQuery.cs | 2 +- .../Identity/User/InsertUserClaimQuery.cs | 2 +- .../Identity/User/InsertUserLoginQuery.cs | 2 +- .../Queries/Identity/User/InsertUserQuery.cs | 2 +- .../Identity/User/InsertUserRoleQuery.cs | 2 +- .../Queries/Identity/User/IsInRoleQuery.cs | 2 +- .../Identity/User/RemoveClaimsQuery.cs | 2 +- .../Identity/User/RemoveLoginForUserQuery.cs | 2 +- .../Identity/User/RemoveUserFromRoleQuery.cs | 2 +- .../Identity/User/SelectUserByEmailQuery.cs | 2 +- .../Identity/User/SelectUserByIdQuery.cs | 2 +- .../User/SelectUserByUserNameQuery.cs | 2 +- .../Identity/User/UpdateClaimForUserQuery.cs | 2 +- .../Queries/Identity/User/UpdateUserQuery.cs | 2 +- .../DeleteInventoryByGroupIdQuery.cs | 2 +- .../Inventory/SelectInventoryByDIdQuery.cs | 2 +- .../SelectInventoryByInventoryIdQuery.cs | 2 +- .../Inventory/SelectInventoryByTypeIdQuery.cs | 2 +- .../Invites/SelectInviteByCodeQuery.cs | 2 +- .../Invites/SelectInviteByEmailQuery.cs | 2 +- .../Logs/SelecAllLogsByDidYearQuery.cs | 2 +- .../Logs/SelectCallLogsByCallIdQuery.cs | 2 +- .../Logs/SelectCallLogsByUserIdQuery.cs | 2 +- .../Logs/SelectLogAttachmentByLogIdQuery.cs | 2 +- .../Logs/SelectLogUnitsByLogIdQuery.cs | 2 +- .../Logs/SelectLogUsersByLogIdQuery.cs | 2 +- .../Logs/SelectLogUsersByUserIdQuery.cs | 2 +- .../Queries/Logs/SelectLogYearsByDeptQuery.cs | 2 +- .../Queries/Logs/SelectLogsByCallIdQuery.cs | 2 +- .../Queries/Logs/SelectLogsByGroupIdQuery.cs | 2 +- .../Queries/Logs/SelectLogsByUserIdQuery.cs | 2 +- .../Queries/Mapping/SelectPoiTypeByIdQuery.cs | 2 +- .../Mapping/SelectPoiTypesByDIdQuery.cs | 2 +- .../SelectInboxMessagesByUserQuery.cs | 2 +- .../Messages/SelectMessageByIdQuery.cs | 2 +- .../SelectMessageRecpByMessageUsQuery.cs | 2 +- .../Messages/SelectMessageRecpsByUserQuery.cs | 2 +- .../Messages/SelectMessagesByUserQuery.cs | 2 +- .../Messages/SelectSentMessagesByUserQuery.cs | 2 +- .../Messages/SelectUnreadMessageCountQuery.cs | 2 +- .../UpdateRecievedMessagesAsDeletedQuery.cs | 2 +- .../UpdateRecievedMessagesAsReadQuery.cs | 2 +- .../Queries/Notes/SelectNotesByDIdQuery.cs | 2 +- .../SelectGetDepartmentPlanCountsQuery.cs | 2 +- .../Payments/SelectPaymentByIdQuery.cs | 2 +- .../SelectPaymentByTransactionIdQuery.cs | 2 +- .../Payments/SelectPaymentsByDIdQuery.cs | 2 +- .../SelectPermissionByDepartmentTypeQuery.cs | 2 +- .../SelectRoleByDidAndNameQuery.cs | 2 +- .../SelectRoleUsersByDidQuery.cs | 21 +- .../SelectRoleUsersByRoleQuery.cs | 21 +- .../SelectRoleUsersByUserQuery.cs | 23 +- .../SelectRolesByDidAndUserQuery.cs | 23 +- .../PersonnelRoles/SelectRolesByDidQuery.cs | 2 +- .../SelectRolesByRoleIdQuery.cs | 2 +- .../Queries/Plans/SelectPlanByPlanIdQuery.cs | 2 +- .../SelectProtocolAttachmentsByProIdQuery.cs | 2 +- .../Protocols/SelectProtocolByIdQuery.cs | 2 +- .../SelectProtocolQuestionsByProIdQuery.cs | 2 +- .../SelectProtocolTriggersByProIdQuery.cs | 2 +- .../Protocols/SelectProtocolsByDIdQuery.cs | 2 +- .../Queues/SelectQueueItemByTypeQuery.cs | 2 +- .../SelectAllItemsByOrderIdQuery.cs | 2 +- .../SelectAllOpenNonDVisibleOrdersQuery.cs | 2 +- .../SelectAllOpenOrdersQuery.cs | 2 +- .../SelectItemsByResourceOrderIdQuery.cs | 2 +- .../ResourceOrders/SelectOrderByIdQuery.cs | 2 +- .../SelectOrderFillUnitsByFillIdQuery.cs | 2 +- .../UpdateOrderFillStatusQuery.cs | 2 +- ...tAllUpcomingOrRecurringReportTasksQuery.cs | 2 +- ...electOpenShiftSignupTradesByUserIdQuery.cs | 2 +- .../Shifts/SelectShiftAndDaysByDIdQuery.cs | 2 +- .../SelectShiftAndDaysByShiftIdQuery.cs | 2 +- .../Queries/Shifts/SelectShiftAndDaysQuery.cs | 2 +- .../SelectShiftAssignmentByGroupQuery.cs | 2 +- .../Shifts/SelectShiftByShiftIdQuery.cs | 2 +- .../Queries/Shifts/SelectShiftDayByIdQuery.cs | 2 +- .../Shifts/SelectShiftDaysByShiftIdQuery.cs | 2 +- .../Shifts/SelectShiftGroupByGroupQuery.cs | 2 +- .../Shifts/SelectShiftGroupByShiftIdQuery.cs | 2 +- .../SelectShiftGroupRolesByGroupIdQuery.cs | 2 +- .../Shifts/SelectShiftPersonByShiftIdQuery.cs | 2 +- .../SelectShiftSignupByShiftIdDateQuery.cs | 2 +- .../Shifts/SelectShiftSignupByShiftIdQuery.cs | 2 +- .../Shifts/SelectShiftSignupByUserIdQuery.cs | 2 +- .../SelectShiftSignupTradeBySourceIdQuery.cs | 2 +- .../SelectShiftSignupTradeByTargetIdQuery.cs | 2 +- .../SelectShiftSignupTradeByUserIdQuery.cs | 2 +- ...lectShiftSignupTradeUsersByTradeIdQuery.cs | 2 +- ...SelectShiftSignupsByGroupIdAndDateQuery.cs | 2 +- .../Shifts/SelectShiftStaffingByDayQuery.cs | 2 +- .../SelectShiftTradeAndSourceByUserIdQuery.cs | 2 +- .../SelectTrainingAttachmentsBytIdQuery.cs | 2 +- .../Trainings/SelectTrainingByIdQuery.cs | 2 +- .../SelectTrainingQuestionsByTrainIdQuery.cs | 2 +- .../SelectTrainingUserByTandUIdQuery.cs | 2 +- .../Trainings/SelectTrainingsByDIdQuery.cs | 2 +- .../SelectUnitStatesByUnitInDateRangeQuery.cs | 2 +- .../DeleteUnitActiveRolesByUnitIdQuery.cs | 2 +- .../SelectActiveRolesForUnitsByDidQuery.cs | 2 +- .../Units/SelectCurrentRolesByUnitIdQuery.cs | 2 +- .../Units/SelectLastUnitStateByUnitIdQuery.cs | 2 +- .../SelectLastUnitStateByUnitIdTimeQuery.cs | 2 +- .../Units/SelectLastUnitStatesByDidQuery.cs | 2 +- .../Units/SelectLatestUnitLocationByUnitId.cs | 2 +- ...lectLatestUnitLocationByUnitIdTimeQuery.cs | 2 +- .../SelectUnitActiveRolesByUnitIdQuery.cs | 2 +- .../Queries/Units/SelectUnitByDIdNameQuery.cs | 2 +- .../Queries/Units/SelectUnitByDIdTypeQuery.cs | 2 +- .../Units/SelectUnitLogsByUnitIdQuery.cs | 2 +- .../Units/SelectUnitRolesByUnitIdQuery.cs | 2 +- .../SelectUnitStateByUnitStateIdQuery.cs | 2 +- .../Units/SelectUnitStatesByCallIdQuery.cs | 2 +- .../Units/SelectUnitStatesByUnitIdQuery.cs | 2 +- .../Units/SelectUnitTypeByDIdNameQuery.cs | 2 +- .../Queries/Units/SelectUnitsByDIdQuery.cs | 23 +- .../Units/SelectUnitsByGroupIdQuery.cs | 23 +- .../SelectAllNonDeletedProfilesByDIdQuery.cs | 2 +- .../SelectAllProfilesByDIdQuery.cs | 2 +- .../UserProfiles/SelectProfileByHomeQuery.cs | 2 +- .../SelectProfileByMobileQuery.cs | 2 +- .../SelectProfileByUserIdQuery.cs | 2 +- .../UserProfiles/SelectProfilesByIdsQuery.cs | 2 +- .../SelectLastUserStatesByUserIdQuery.cs | 2 +- .../SelectLatestUserStatesByDidQuery.cs | 2 +- .../SelectPreviousUserStatesByUserIdQuery.cs | 2 +- .../SelectUserStatesByDIdDateRangeQuery.cs | 2 +- .../SelectUserStatesByUserIdQuery.cs | 2 +- .../Queries/Voice/SelectVoiceByDIdQuery.cs | 2 +- .../Voice/SelectVoiceChannelsByDIdQuery.cs | 2 +- .../SelectVoiceChannelsByVoiceIdQuery.cs | 2 +- .../Voice/SelectVoiceUserByUserIdQuery.cs | 2 +- .../SelectAllWorkshiftsAndDaysByDidQuery.cs | 2 +- .../Workshifts/SelectWorkshiftByIdQuery.cs | 2 +- ...lectWorkshiftEntitiesByWorkshiftIdQuery.cs | 2 +- .../SelectWorkshiftFillsByWorkshiftIdQuery.cs | 2 +- .../QueueItemsRepository.cs | 2 +- .../RepositoryBase.cs | 29 +- ...Resgrid.Repositories.DataRepository.csproj | 4 + .../ResourceOrderFillRepository.cs | 2 +- .../ResourceOrderFillUnitRepository.cs | 2 +- .../ResourceOrderItemRepository.cs | 2 +- .../ResourceOrdersRepository.cs | 6 +- .../ScheduledTasksRepository.cs | 8 +- .../PostgreSql/PostgreSqlConfiguration.cs | 1386 +++++++++++++++++ .../PostgreSqlConnectionProvider.cs | 14 + .../SqlServer/SqlServerConfiguration.cs | 48 +- .../ShiftDaysRepository.cs | 4 +- .../ShiftGroupAssignmentsRepository.cs | 2 +- .../ShiftGroupRolesRepository.cs | 2 +- .../ShiftGroupsRepository.cs | 4 +- .../ShiftPersonRepository.cs | 2 +- .../ShiftSignupRepository.cs | 8 +- .../ShiftSignupTradeRepository.cs | 10 +- .../ShiftSignupTradeUserRepository.cs | 2 +- .../ShiftStaffingRepository.cs | 2 +- .../ShiftsRepository.cs | 157 +- .../TrainingAttachmentRepository.cs | 2 +- .../TrainingQuestionRepository.cs | 2 +- .../TrainingRepository.cs | 4 +- .../TrainingUserRepository.cs | 2 +- .../UnitActiveRolesRepository.cs | 8 +- .../UnitLocationRepository.cs | 4 +- .../UnitLogsRepository.cs | 2 +- .../UnitRolesRepository.cs | 2 +- .../UnitStateRoleRepository.cs | 2 +- .../UnitStatesRepository.cs | 14 +- .../UnitTypesRepository.cs | 2 +- .../UnitsRepository.cs | 8 +- .../UserProfilesRepository.cs | 14 +- .../UserStatesRepository.cs | 10 +- .../WorkshiftEntitysRepository.cs | 2 +- .../WorkshiftFillsRepository.cs | 2 +- .../WorkshiftsRepository.cs | 4 +- .../MapLayersDocRepository.cs | 94 ++ .../NoSqlDataModule.cs | 4 + .../PersonnelLocationsDocRepository.cs | 105 ++ ...esgrid.Repositories.NoSqlRepository.csproj | 3 + .../UnitLocationsDocRepository.cs | 105 ++ Resgrid.sln | 57 + .../Resgrid.Console/Args/MigrateDocsDbArgs.cs | 7 + .../Commands/MigrateDocsDbCommand.cs | 105 ++ .../Commands/OidcUpdateCommand.cs | 2 +- .../Properties/launchSettings.json | 2 +- .../Controllers/v4/CalendarController.cs | 1 - .../Views/Dispatch/AddArchivedCall.cshtml | 4 +- .../User/Views/Dispatch/UpdateCall.cshtml | 4 +- Workers/Resgrid.Workers.Console/Program.cs | 118 +- .../Properties/launchSettings.json | 5 +- .../Resgrid.Workers.Console.csproj | 2 + .../PostgresQuidjiboConfiguration.cs | 48 + .../Extensions/NpgsqlCommandExtensions.cs | 78 + .../NpgsqlParameterCollectionExtensions.cs | 13 + .../Extensions/QuidjiboBuilderExtensions.cs | 95 ++ .../PostgresProgressProviderFactory.cs | 59 + .../PostgresScheduleProviderFactory.cs | 54 + .../Factories/PostgresWorkProviderFactory.cs | 63 + .../Providers/PostgresProgressProvider.cs | 79 + .../Providers/PostgresScheduleProvider.cs | 167 ++ .../Providers/PostgresWorkProvider.cs | 160 ++ .../Quidjibo.Postgres.csproj | 72 + .../Scripts/Progress/Create.sql | 22 + .../Scripts/Progress/LoadByCorrelationId.sql | 3 + .../Scripts/Progress/Setup.sql | 23 + .../Scripts/Schedule/Complete.sql | 4 + .../Scripts/Schedule/Create.sql | 24 + .../Scripts/Schedule/Delete.sql | 1 + .../Scripts/Schedule/Exists.sql | 3 + .../Scripts/Schedule/List.sql | 1 + .../Scripts/Schedule/Load.sql | 3 + .../Scripts/Schedule/LoadByName.sql | 3 + .../Scripts/Schedule/Receive.sql | 15 + .../Scripts/Schedule/Setup.sql | 24 + .../Scripts/Schema/Setup.sql | 1 + .../Scripts/Work/Complete.sql | 5 + .../Quidjibo.Postgres/Scripts/Work/Fault.sql | 5 + .../Quidjibo.Postgres/Scripts/Work/List.sql | 1 + .../Scripts/Work/Receive.sql | 23 + .../Quidjibo.Postgres/Scripts/Work/Renew.sql | 3 + .../Quidjibo.Postgres/Scripts/Work/Send.sql | 30 + .../Quidjibo.Postgres/Scripts/Work/Setup.sql | 27 + .../Quidjibo.Postgres/Utils/PostgresRunner.cs | 59 + .../Quidjibo.Postgres/Utils/SqlLoader.cs | 31 + 434 files changed, 5887 insertions(+), 900 deletions(-) create mode 100644 Core/Resgrid.Model/Repositories/IMapLayersRepository.cs create mode 100644 Core/Resgrid.Model/Repositories/IPersonnelLocationsDocRepository.cs create mode 100644 Core/Resgrid.Model/Repositories/IUnitLocationsDocRepository.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0001_InitialMigrationPg.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0002_AddingContacts.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0003_AddingUnitActiveRoles.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0004_AddingSortToTemplates.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0005_AddingForms.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0006_AddingFormDataToCalls.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0007_AddingDispatchOnToCalls.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0008_AddingAddonsInvoices.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0009_AddingDepartmentVoice.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0010_AddingSystemAudits.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0011_AddingAutofills.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0012_UpdatingUnitCallTypes.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0013_UpdatingLinkedCall.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0014_AddingWorkshifts.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0015_AddingMissingWorkshiftValues.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0016_AddingUnifiedPlan.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0017_AddingToAuditTable.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0018_AddingToCallNotesAndFiles.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0019_AddingDeleteReasonToCalls.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0020_AddingLangToUPAndSystemQ.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0021_AddingCallReferences.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0022_AddingQuantityForPlanAddon.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0023_AddingPlanAddonFor10Pack.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0024_AddingDepartmentAudio.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0025_AddingTypeToDepartmentAudio.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0026_AddingEntityPlan.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0027_AddingFreeEntityLimits.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0028_AddingDeletedWorkshiftColumns.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0029_AddingCustomStateDetailColumns.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0030_AddingDocumentCategories.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Migrations/M0031_AddingNoteCategories.cs create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Sql/EF0001_PopulateOIDCDb.sql create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Sql/EF0003_PopulateDocDb.sql create mode 100644 Providers/Resgrid.Providers.MigrationsPg/Sql/M0001_InitialMigration.sql create mode 100644 Repositories/Resgrid.Repositories.DataRepository/Extensions/CitextParameter.cs create mode 100644 Repositories/Resgrid.Repositories.DataRepository/Extensions/DynamicParametersExtension.cs create mode 100644 Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConfiguration.cs create mode 100644 Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConnectionProvider.cs create mode 100644 Repositories/Resgrid.Repositories.NoSqlRepository/MapLayersDocRepository.cs create mode 100644 Repositories/Resgrid.Repositories.NoSqlRepository/PersonnelLocationsDocRepository.cs create mode 100644 Repositories/Resgrid.Repositories.NoSqlRepository/UnitLocationsDocRepository.cs create mode 100644 Tools/Resgrid.Console/Args/MigrateDocsDbArgs.cs create mode 100644 Tools/Resgrid.Console/Commands/MigrateDocsDbCommand.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Configurations/PostgresQuidjiboConfiguration.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlCommandExtensions.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlParameterCollectionExtensions.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Extensions/QuidjiboBuilderExtensions.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Factories/PostgresProgressProviderFactory.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Factories/PostgresScheduleProviderFactory.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Factories/PostgresWorkProviderFactory.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Providers/PostgresProgressProvider.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Providers/PostgresScheduleProvider.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Providers/PostgresWorkProvider.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Progress/Create.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Progress/LoadByCorrelationId.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Progress/Setup.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Complete.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Create.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Delete.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Exists.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/List.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Load.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/LoadByName.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Receive.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Setup.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Schema/Setup.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/Complete.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/Fault.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/List.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/Receive.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/Renew.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/Send.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Scripts/Work/Setup.sql create mode 100644 Workers/Support/Quidjibo.Postgres/Utils/PostgresRunner.cs create mode 100644 Workers/Support/Quidjibo.Postgres/Utils/SqlLoader.cs diff --git a/Core/Resgrid.Config/DataConfig.cs b/Core/Resgrid.Config/DataConfig.cs index 3e2f454b..be3bbdab 100644 --- a/Core/Resgrid.Config/DataConfig.cs +++ b/Core/Resgrid.Config/DataConfig.cs @@ -2,8 +2,29 @@ { public class DataConfig { + /// + /// The underlying database engine + /// + public static DatabaseTypes DatabaseType = DatabaseTypes.SqlServer; + + /// + /// The underlying database engine for the document database (does not support SqlServer) + /// + public static DatabaseTypes DocDatabaseType = DatabaseTypes.MongoDb; + public static string ConnectionString = "Server=rgdevserver;Database=Resgrid;User Id=resgrid_app;Password=resgrid123;MultipleActiveResultSets=True;TrustServerCertificate=True;"; + /// + /// Connection string for the core relational Resgrid database + /// + public static string CoreConnectionString = ""; + + /// + /// Connection string for storing JSON document types (Postgres) + /// + public static string DocumentConnectionString = ""; + + public static string NoSqlConnectionString = "mongodb://resgrid:resgrid123@rgdevserver:27017"; public static string NoSqlDatabaseName = "resgrid"; public static string NoSqlApplicationName = "Resgrid"; @@ -11,5 +32,13 @@ public class DataConfig public static string UsersIdentityRoleId = "38b461d7-e848-46ef-8c06-ece5b618d9d1"; public static string AdminsIdentityRoleId = "1f6a03a8-62f4-4179-80fc-2eb96266cf04"; public static string AffiliatesIdentityRoleId = "3aba8863-e46d-40cc-ab86-309f9c3e4f97"; + public static string QueryPrefix = ""; + } + + public enum DatabaseTypes + { + SqlServer, + Postgres, + MongoDb } } diff --git a/Core/Resgrid.Config/OidcConfig.cs b/Core/Resgrid.Config/OidcConfig.cs index 45b8cd9a..4cf2df18 100644 --- a/Core/Resgrid.Config/OidcConfig.cs +++ b/Core/Resgrid.Config/OidcConfig.cs @@ -6,6 +6,11 @@ namespace Resgrid.Config { public static class OidcConfig { + /// + /// The underlying database engine for the OIDC database (Does not support Mongo) + /// + public static DatabaseTypes DatabaseType = DatabaseTypes.SqlServer; + public static string Key = ""; public static string ConnectionString = "Server=rgdevserver;Database=ResgridOIDC;User Id=resgrid_odic;Password=resgrid123;MultipleActiveResultSets=True;TrustServerCertificate=True;"; diff --git a/Core/Resgrid.Config/WorkerConfig.cs b/Core/Resgrid.Config/WorkerConfig.cs index 43ea2c83..a1e13233 100644 --- a/Core/Resgrid.Config/WorkerConfig.cs +++ b/Core/Resgrid.Config/WorkerConfig.cs @@ -2,6 +2,11 @@ { public static class WorkerConfig { + /// + /// The underlying database engine for the worker database (Does not support Mongo) + /// + public static DatabaseTypes DatabaseType = DatabaseTypes.SqlServer; + public static string WorkerDbConnectionString = "Server=rgdevserver;Database=ResgridWorkers;User Id=resgrid_workers;Password=resgrid123;MultipleActiveResultSets=True;"; public static string PayloadKey = "XsBYpdbdHkhuGsU3tvTMawyV6d3M2F8EQ8wQ2jVLBREECQmwngACk2hm4Ykb7eW7Qsm6za8RdJBY5Z3xvN6erYry47nJ5XmL"; } diff --git a/Core/Resgrid.Model/MapLayer.cs b/Core/Resgrid.Model/MapLayer.cs index 9dc9ea4f..e7862d9d 100644 --- a/Core/Resgrid.Model/MapLayer.cs +++ b/Core/Resgrid.Model/MapLayer.cs @@ -12,43 +12,67 @@ namespace Resgrid.Model public class MapLayer: NoSqlDocument { [BsonElement("departmentId")] + [JsonProperty(PropertyName = "departmentId")] public int DepartmentId { get; set; } [Required] [MaxLength(250)] [BsonElement("name")] + [JsonProperty(PropertyName = "name")] public string Name { get; set; } [BsonElement("type")] + [JsonProperty(PropertyName = "type")] public int Type { get; set; } [Required] [MaxLength(50)] [BsonElement("color")] + [JsonProperty(PropertyName = "color")] public string Color { get; set; } [BsonElement("data")] + [JsonProperty(PropertyName = "data")] public MapLayerData Data { get; set; } [BsonElement("isSearchable")] + [JsonProperty(PropertyName = "isSearchable")] public bool IsSearchable { get; set; } [BsonElement("isOnByDefault")] + [JsonProperty(PropertyName = "isOnByDefault")] public bool IsOnByDefault { get; set; } [BsonElement("addedById")] + [JsonProperty(PropertyName = "addedById")] public string AddedById { get; set; } [BsonElement("addedOn")] + [JsonProperty(PropertyName = "addedOn")] public DateTime AddedOn { get; set; } [BsonElement("isDeleted")] + [JsonProperty(PropertyName = "isDeleted")] public bool IsDeleted { get; set; } [BsonElement("updatedById")] + [JsonProperty(PropertyName = "updatedById")] public string UpdatedById { get; set; } [BsonElement("updatedOn")] + [JsonProperty(PropertyName = "updatedOn")] public DateTime UpdatedOn { get; set; } + + [BsonIgnore()] + [JsonProperty(PropertyName = "id")] + public string PgId { get; set; } + + public string GetId() + { + if (!String.IsNullOrWhiteSpace(PgId)) + return PgId; + + return Id.ToString(); + } } } diff --git a/Core/Resgrid.Model/PersonnelLocation.cs b/Core/Resgrid.Model/PersonnelLocation.cs index 53fc822a..47daa2b0 100644 --- a/Core/Resgrid.Model/PersonnelLocation.cs +++ b/Core/Resgrid.Model/PersonnelLocation.cs @@ -39,5 +39,16 @@ public class PersonnelLocation : NoSqlDocument [BsonElement("heading")] public decimal? Heading { get; set; } + + [BsonIgnore()] + public string PgId { get; set; } + + public string GetId() + { + if (!String.IsNullOrWhiteSpace(PgId)) + return PgId; + + return Id.ToString(); + } } } diff --git a/Core/Resgrid.Model/Repositories/IMapLayersRepository.cs b/Core/Resgrid.Model/Repositories/IMapLayersRepository.cs new file mode 100644 index 00000000..89694c98 --- /dev/null +++ b/Core/Resgrid.Model/Repositories/IMapLayersRepository.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Resgrid.Model.Repositories +{ + public interface IMapLayersDocRepository + { + Task> GetAllMapLayersByDepartmentIdAsync(int departmentId, MapLayerTypes type); + Task GetByIdAsync(string id); + Task GetByOldIdAsync(string id); + Task InsertAsync(MapLayer mapLayer); + Task UpdateAsync(MapLayer mapLayer); + } +} diff --git a/Core/Resgrid.Model/Repositories/IOidcRepository.cs b/Core/Resgrid.Model/Repositories/IOidcRepository.cs index b135ffcc..48ec410d 100644 --- a/Core/Resgrid.Model/Repositories/IOidcRepository.cs +++ b/Core/Resgrid.Model/Repositories/IOidcRepository.cs @@ -1,4 +1,6 @@ -namespace Resgrid.Model.Repositories +using System.Threading.Tasks; + +namespace Resgrid.Model.Repositories { /// /// Interface IOidcRepository @@ -9,6 +11,6 @@ public interface IOidcRepository /// Updates the Oidc Database /// /// If the operation was successful - bool UpdateOidcDatabase(); + Task UpdateOidcDatabaseAsync(); } } diff --git a/Core/Resgrid.Model/Repositories/IPersonnelLocationsDocRepository.cs b/Core/Resgrid.Model/Repositories/IPersonnelLocationsDocRepository.cs new file mode 100644 index 00000000..3464fb8a --- /dev/null +++ b/Core/Resgrid.Model/Repositories/IPersonnelLocationsDocRepository.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Resgrid.Model.Repositories +{ + public interface IPersonnelLocationsDocRepository + { + Task> GetAllLocationsByUnitIdAsync(string userId); + Task GetLatestLocationsByUnitIdAsync(string userId); + Task> GetLatestLocationsByDepartmentIdAsync(int departmentId); + Task GetByIdAsync(string id); + Task GetByOldIdAsync(string id); + Task InsertAsync(PersonnelLocation location); + } +} diff --git a/Core/Resgrid.Model/Repositories/IUnitLocationsDocRepository.cs b/Core/Resgrid.Model/Repositories/IUnitLocationsDocRepository.cs new file mode 100644 index 00000000..3fb3b9c5 --- /dev/null +++ b/Core/Resgrid.Model/Repositories/IUnitLocationsDocRepository.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Resgrid.Model.Repositories +{ + public interface IUnitLocationsDocRepository + { + Task> GetAllLocationsByUnitIdAsync(int unitId); + Task GetLatestLocationsByUnitIdAsync(int unitId); + Task> GetLatestLocationsByDepartmentIdAsync(int departmentId); + Task GetByIdAsync(string id); + Task GetByOldIdAsync(string id); + Task InsertAsync(UnitsLocation location); + } +} diff --git a/Core/Resgrid.Model/UnitsLocation.cs b/Core/Resgrid.Model/UnitsLocation.cs index 2ddaa231..b4b4cf79 100644 --- a/Core/Resgrid.Model/UnitsLocation.cs +++ b/Core/Resgrid.Model/UnitsLocation.cs @@ -39,5 +39,16 @@ public class UnitsLocation : NoSqlDocument [BsonElement("heading")] public decimal? Heading { get; set; } + + [BsonIgnore()] + public string PgId { get; set; } + + public string GetId() + { + if (!String.IsNullOrWhiteSpace(PgId)) + return PgId; + + return Id.ToString(); + } } } diff --git a/Core/Resgrid.Services/MappingService.cs b/Core/Resgrid.Services/MappingService.cs index 2dbda040..b88c09b7 100644 --- a/Core/Resgrid.Services/MappingService.cs +++ b/Core/Resgrid.Services/MappingService.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -13,12 +14,15 @@ public class MappingService : IMappingService private readonly IPoiTypesRepository _poiTypesRepository; private readonly IPoisRepository _poisRepository; private readonly IMongoRepository _mapLayersRepository; + private readonly IMapLayersDocRepository _mapLayersDocRepository; - public MappingService(IPoiTypesRepository poiTypesRepository, IPoisRepository poisRepository, IMongoRepository mapLayersRepository) + public MappingService(IPoiTypesRepository poiTypesRepository, IPoisRepository poisRepository, IMongoRepository mapLayersRepository, + IMapLayersDocRepository mapLayersDocRepository) { _poiTypesRepository = poiTypesRepository; _poisRepository = poisRepository; _mapLayersRepository = mapLayersRepository; + _mapLayersDocRepository = mapLayersDocRepository; } public async Task SavePOITypeAsync(PoiType type, CancellationToken cancellationToken = default(CancellationToken)) @@ -59,26 +63,56 @@ public async Task GetTypeByIdAsync(int poiTypeId) public async Task SaveMapLayerAsync(MapLayer mapLayer) { - if (mapLayer.Id.Timestamp == 0) - await _mapLayersRepository.InsertOneAsync(mapLayer); + if (Config.DataConfig.DocDatabaseType == Config.DatabaseTypes.Postgres) + { + if (String.IsNullOrEmpty(mapLayer.PgId)) + await _mapLayersDocRepository.InsertAsync(mapLayer); + else + await _mapLayersDocRepository.UpdateAsync(mapLayer); + + return mapLayer; + } else - await _mapLayersRepository.ReplaceOneAsync(mapLayer); + { + if (mapLayer.Id.Timestamp == 0) + await _mapLayersRepository.InsertOneAsync(mapLayer); + else + await _mapLayersRepository.ReplaceOneAsync(mapLayer); - return mapLayer; + return mapLayer; + } } public async Task> GetMapLayersForTypeDepartmentAsync(int departmentId, MapLayerTypes type) { - var layers = await _mapLayersRepository.FilterByAsync(filter => filter.DepartmentId == departmentId && filter.Type == (int)type && filter.IsDeleted == false); + if (Config.DataConfig.DocDatabaseType == Config.DatabaseTypes.Postgres) + { + var layers = await _mapLayersDocRepository.GetAllMapLayersByDepartmentIdAsync(departmentId, type); - return layers.ToList(); + return layers; + } + else + { + var layers = await _mapLayersRepository.FilterByAsync(filter => filter.DepartmentId == departmentId && filter.Type == (int)type && filter.IsDeleted == false); + + return layers.ToList(); + } } public async Task GetMapLayersByIdAsync(string id) { - var layers = await _mapLayersRepository.FindByIdAsync(id); + if (Config.DataConfig.DocDatabaseType == Config.DatabaseTypes.Postgres) + { + var layers = await _mapLayersDocRepository.GetByIdAsync(id); + + return layers; + } + else + { + var layers = await _mapLayersRepository.FindByIdAsync(id); - return layers; + return layers; + } } } } diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0001_InitialMigrationPg.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0001_InitialMigrationPg.cs new file mode 100644 index 00000000..7954aafd --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0001_InitialMigrationPg.cs @@ -0,0 +1,18 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(1)] + public class M0001_InitialMigrationPg : Migration + { + public override void Up() + { + Execute.EmbeddedScript("Resgrid.Providers.MigrationsPg.Sql.M0001_InitialMigration.sql"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0002_AddingContacts.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0002_AddingContacts.cs new file mode 100644 index 00000000..f4a4b204 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0002_AddingContacts.cs @@ -0,0 +1,39 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(2)] + public class M0002_AddingContacts : Migration + { + public override void Up() + { + Create.Table("Contacts") + .WithColumn("ContactId").AsInt32().NotNullable().PrimaryKey().Identity() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("ContactTypeId").AsInt32() + .WithColumn("Name").AsCustom("citext").NotNullable() + .WithColumn("PhoneNumber").AsCustom("citext") + .WithColumn("FaxNumber").AsCustom("citext") + .WithColumn("Email").AsCustom("citext") + .WithColumn("Twitter").AsCustom("citext") + .WithColumn("Facebook").AsCustom("citext") + .WithColumn("Notes").AsCustom("citext") + .WithColumn("Address").AsCustom("citext") + .WithColumn("City").AsCustom("citext") + .WithColumn("State").AsCustom("citext") + .WithColumn("PostalCode").AsCustom("citext") + .WithColumn("Country").AsCustom("citext") + .WithColumn("Location").AsCustom("citext"); + + + Create.ForeignKey("FK_Conacts_Departments") + .FromTable("Contacts").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + } + + public override void Down() + { + Delete.Table("Contacts"); + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0003_AddingUnitActiveRoles.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0003_AddingUnitActiveRoles.cs new file mode 100644 index 00000000..d06469e2 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0003_AddingUnitActiveRoles.cs @@ -0,0 +1,33 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(3)] + public class M0003_AddingUnitActiveRoles : Migration + { + public override void Up() + { + Create.Table("UnitActiveRoles") + .WithColumn("UnitActiveRoleId").AsInt32().NotNullable().PrimaryKey().Identity() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("UnitId").AsInt32().NotNullable() + .WithColumn("Role").AsCustom("citext").NotNullable() + .WithColumn("UserId").AsCustom("citext").NotNullable() + .WithColumn("UpdatedOn").AsDateTime().NotNullable() + .WithColumn("UpdatedBy").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_UnitActiveRoles_Departments") + .FromTable("UnitActiveRoles").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + + Create.ForeignKey("FK_UnitActiveRoles_Units") + .FromTable("UnitActiveRoles").ForeignColumn("UnitId") + .ToTable("Units").PrimaryColumn("UnitId"); + } + + public override void Down() + { + Delete.Table("UnitActiveRoles"); + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0004_AddingSortToTemplates.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0004_AddingSortToTemplates.cs new file mode 100644 index 00000000..22dfac41 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0004_AddingSortToTemplates.cs @@ -0,0 +1,18 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(4)] + public class M0004_AddingSortToTemplates : Migration + { + public override void Up() + { + Alter.Table("CallQuickTemplates").AddColumn("Sort").AsInt32().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0005_AddingForms.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0005_AddingForms.cs new file mode 100644 index 00000000..004e0a63 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0005_AddingForms.cs @@ -0,0 +1,48 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(5)] + public class M0005_AddingForms : Migration + { + public override void Up() + { + Create.Table("Forms") + .WithColumn("FormId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("Type").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext").NotNullable() + .WithColumn("IsActive").AsBoolean() + .WithColumn("IsDeleted").AsBoolean() + .WithColumn("Data").AsCustom("citext") + .WithColumn("CreatedOn").AsDateTime2() + .WithColumn("CreatedBy").AsCustom("citext") + .WithColumn("UpdatedOn").AsDateTime2() + .WithColumn("UpdatedBy").AsCustom("citext"); + + Create.Table("FormAutomations") + .WithColumn("FormAutomationId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("FormId").AsCustom("citext").NotNullable() + .WithColumn("TriggerField").AsCustom("citext").NotNullable() + .WithColumn("TriggerValue").AsCustom("citext") + .WithColumn("OperationType").AsInt32().NotNullable() + .WithColumn("OperationValue").AsCustom("citext"); + + + Create.ForeignKey("FK_Forms_Departments") + .FromTable("Forms").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + + Create.ForeignKey("FK_FormAutomations_Forms") + .FromTable("FormAutomations").ForeignColumn("FormId") + .ToTable("Forms").PrimaryColumn("FormId"); + } + + public override void Down() + { + Delete.Table("Forms"); + Delete.Table("FormAutomations"); + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0006_AddingFormDataToCalls.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0006_AddingFormDataToCalls.cs new file mode 100644 index 00000000..0f10b76e --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0006_AddingFormDataToCalls.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(6)] + public class M0006_AddingFormDataToCalls : Migration + { + public override void Up() + { + Alter.Table("Calls").AddColumn("CallFormData").AsCustom("citext").Nullable(); + Alter.Table("Calls").AddColumn("ContactId").AsInt32().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0007_AddingDispatchOnToCalls.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0007_AddingDispatchOnToCalls.cs new file mode 100644 index 00000000..ca5a983a --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0007_AddingDispatchOnToCalls.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(7)] + public class M0007_AddingDispatchOnToCalls : Migration + { + public override void Up() + { + Alter.Table("Calls").AddColumn("DispatchOn").AsDateTime2().Nullable(); + Alter.Table("Calls").AddColumn("HasBeenDispatched").AsBoolean().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0008_AddingAddonsInvoices.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0008_AddingAddonsInvoices.cs new file mode 100644 index 00000000..a04289ea --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0008_AddingAddonsInvoices.cs @@ -0,0 +1,62 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(8)] + public class M0008_AddingAddonsInvoices : Migration + { + public override void Up() + { + // Adding in Invoice limits + + // Enterprise Plus Plan Invoice Limits + Insert.IntoTable("PlanLimits").Row(new { PlanId = 1, LimitType = 5, LimitValue = 100000 }); + + // Finish Adding in Invoice limits + + Create.Table("PlanAddons") + .WithColumn("PlanAddonId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("PlanId").AsInt32().NotNullable() + .WithColumn("AddonType").AsInt32().NotNullable() + .WithColumn("Cost").AsDecimal().NotNullable() + .WithColumn("ExternalId").AsCustom("citext"); + + Create.ForeignKey("FK_PlanAddons_Plans") + .FromTable("PlanAddons").ForeignColumn("PlanId") + .ToTable("Plans").PrimaryColumn("PlanId"); + + // Standard Plan PTT Addon + Insert.IntoTable("PlanAddons").Row(new { PlanAddonId = "456ed5d4-57e1-4882-b433-1d3cc239103d", PlanId = 1, AddonType = 1, Cost = 0, ExternalId = "" }); + + Create.Table("PaymentAddons") + .WithColumn("PaymentAddonId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("PlanAddonId").AsCustom("citext").NotNullable() + .WithColumn("PurchaseOn").AsDateTime2().NotNullable() + .WithColumn("EffectiveOn").AsDateTime2().NotNullable() + .WithColumn("EndingOn").AsDateTime2().NotNullable() + .WithColumn("Amount").AsDecimal().NotNullable() + .WithColumn("Description").AsCustom("citext").NotNullable() + .WithColumn("TransactionId").AsCustom("citext").NotNullable() + .WithColumn("SubscriptionId").AsCustom("citext").NotNullable() + .WithColumn("Data").AsCustom("citext").NotNullable() + .WithColumn("IsCancelled").AsBoolean().Nullable() + .WithColumn("CancelledOn").AsDateTime2().Nullable() + .WithColumn("CancelledData").AsCustom("citext").Nullable(); + + Create.ForeignKey("FK_PaymentAddons_Departments") + .FromTable("PaymentAddons").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + + Create.ForeignKey("FK_PaymentAddons_PlanAddons") + .FromTable("PaymentAddons").ForeignColumn("PlanAddonId") + .ToTable("PlanAddons").PrimaryColumn("PlanAddonId"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0009_AddingDepartmentVoice.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0009_AddingDepartmentVoice.cs new file mode 100644 index 00000000..479cfb99 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0009_AddingDepartmentVoice.cs @@ -0,0 +1,56 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(9)] + public class M0009_AddingDepartmentVoice : Migration + { + public override void Up() + { + Create.Table("DepartmentVoices") + .WithColumn("DepartmentVoiceId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("StartConferenceNumber").AsInt32().NotNullable(); + + Create.ForeignKey("FK_DepartmentVoices_Department") + .FromTable("DepartmentVoices").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + + Create.Table("DepartmentVoiceChannels") + .WithColumn("DepartmentVoiceChannelId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentVoiceId").AsCustom("citext").NotNullable() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext") + .WithColumn("SystemConferenceId").AsCustom("citext") + .WithColumn("SystemCallflowId").AsCustom("citext") + .WithColumn("ConferenceNumber").AsInt32() + .WithColumn("IsDefault").AsBoolean(); + + Create.ForeignKey("FK_DepartmentVoiceChannels_Department") + .FromTable("DepartmentVoiceChannels").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + + Create.ForeignKey("FK_DepartmentVoiceChannels_DepartmentVoices") + .FromTable("DepartmentVoiceChannels").ForeignColumn("DepartmentVoiceId") + .ToTable("DepartmentVoices").PrimaryColumn("DepartmentVoiceId"); + + Create.Table("DepartmentVoiceUsers") + .WithColumn("DepartmentVoiceUserId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentVoiceId").AsCustom("citext").NotNullable() + .WithColumn("UserId").AsCustom("citext").NotNullable() + .WithColumn("SystemUserId").AsCustom("citext") + .WithColumn("SystemDeviceId").AsCustom("citext"); + + Create.ForeignKey("FK_DepartmentVoiceUsers_DepartmentVoices") + .FromTable("DepartmentVoiceUsers").ForeignColumn("DepartmentVoiceId") + .ToTable("DepartmentVoices").PrimaryColumn("DepartmentVoiceId"); + + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0010_AddingSystemAudits.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0010_AddingSystemAudits.cs new file mode 100644 index 00000000..37ffb3ac --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0010_AddingSystemAudits.cs @@ -0,0 +1,30 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(10)] + public class M0010_AddingSystemAudits : Migration + { + public override void Up() + { + Create.Table("SystemAudits") + .WithColumn("SystemAuditId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().Nullable() + .WithColumn("Type").AsInt32().NotNullable() + .WithColumn("System").AsInt32().NotNullable() + .WithColumn("UserId").AsCustom("citext").Nullable() + .WithColumn("Username").AsCustom("citext").Nullable() + .WithColumn("IpAddress").AsCustom("citext") + .WithColumn("Data").AsCustom("citext") + .WithColumn("Successful").AsBoolean().NotNullable() + .WithColumn("ServerName").AsCustom("citext") + .WithColumn("LoggedOn").AsDateTime2().NotNullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0011_AddingAutofills.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0011_AddingAutofills.cs new file mode 100644 index 00000000..efcd87e5 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0011_AddingAutofills.cs @@ -0,0 +1,27 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(11)] + public class M0011_AddingAutofills : Migration + { + public override void Up() + { + Create.Table("Autofills") + .WithColumn("AutofillId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().Nullable() + .WithColumn("Type").AsInt32().NotNullable() + .WithColumn("Sort").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext") + .WithColumn("Data").AsCustom("citext") + .WithColumn("AddedByUserId").AsCustom("citext").Nullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0012_UpdatingUnitCallTypes.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0012_UpdatingUnitCallTypes.cs new file mode 100644 index 00000000..e6101e2b --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0012_UpdatingUnitCallTypes.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(12)] + public class M0012_UpdatingUnitCallTypes : Migration + { + public override void Up() + { + Alter.Table("UnitTypes").AddColumn("MapIconType").AsInt32().Nullable(); + Alter.Table("CallTypes").AddColumn("MapIconType").AsInt32().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0013_UpdatingLinkedCall.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0013_UpdatingLinkedCall.cs new file mode 100644 index 00000000..5af775f7 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0013_UpdatingLinkedCall.cs @@ -0,0 +1,19 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(13)] + public class M0013_UpdatingLinkedCall : Migration + { + public override void Up() + { + Alter.Table("Calls").AddColumn("LinkedCallId").AsInt32().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0014_AddingWorkshifts.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0014_AddingWorkshifts.cs new file mode 100644 index 00000000..986a0a13 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0014_AddingWorkshifts.cs @@ -0,0 +1,73 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(14)] + public class M0014_AddingWorkshifts : Migration + { + public override void Up() + { + Create.Table("Workshifts") + .WithColumn("WorkshiftId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("Type").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext").NotNullable() + .WithColumn("Color").AsCustom("citext").NotNullable() + .WithColumn("Start").AsDateTime2().NotNullable() + .WithColumn("End").AsDateTime2().NotNullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable() + .WithColumn("AddedById").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_Workshifts_Department") + .FromTable("Workshifts").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + + Create.Table("WorkshiftDays") + .WithColumn("WorkshiftDayId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("WorkshiftId").AsCustom("citext").NotNullable() + .WithColumn("Day").AsDateTime2().NotNullable() + .WithColumn("Processed").AsBoolean().NotNullable(); + + Create.ForeignKey("FK_WorkshiftDays_Workshifts") + .FromTable("WorkshiftDays").ForeignColumn("WorkshiftId") + .ToTable("Workshifts").PrimaryColumn("WorkshiftId"); + + Create.Table("WorkshiftEntities") + .WithColumn("WorkshiftEntityId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("WorkshiftId").AsCustom("citext").NotNullable() + .WithColumn("BackingId").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_WorkshiftEntities_Workshifts") + .FromTable("WorkshiftEntities").ForeignColumn("WorkshiftId") + .ToTable("Workshifts").PrimaryColumn("WorkshiftId"); + + Create.Table("WorkshiftFills") + .WithColumn("WorkshiftFillId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("WorkshiftId").AsCustom("citext").NotNullable() + .WithColumn("WorkshiftDayId").AsCustom("citext").NotNullable() + .WithColumn("WorkshiftEntityId").AsCustom("citext").NotNullable() + .WithColumn("FilledById").AsInt32().NotNullable() + .WithColumn("Approved").AsBoolean().NotNullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable() + .WithColumn("AddedById").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_WorkshiftFills_Workshifts") + .FromTable("WorkshiftFills").ForeignColumn("WorkshiftId") + .ToTable("Workshifts").PrimaryColumn("WorkshiftId"); + + Create.ForeignKey("FK_WorkshiftFills_WorkshiftDays") + .FromTable("WorkshiftFills").ForeignColumn("WorkshiftDayId") + .ToTable("WorkshiftDays").PrimaryColumn("WorkshiftDayId"); + + Create.ForeignKey("FK_WorkshiftFills_WorkshiftEntities") + .FromTable("WorkshiftFills").ForeignColumn("WorkshiftEntityId") + .ToTable("WorkshiftEntities").PrimaryColumn("WorkshiftEntityId"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0015_AddingMissingWorkshiftValues.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0015_AddingMissingWorkshiftValues.cs new file mode 100644 index 00000000..6e3f4c8b --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0015_AddingMissingWorkshiftValues.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(15)] + public class M0015_AddingMissingWorkshiftValues : Migration + { + public override void Up() + { + Alter.Table("Workshifts").AddColumn("Description").AsCustom("citext").Nullable(); + Alter.Table("WorkshiftFills").AddColumn("ReferenceId").AsCustom("citext").Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0016_AddingUnifiedPlan.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0016_AddingUnifiedPlan.cs new file mode 100644 index 00000000..cef1e27d --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0016_AddingUnifiedPlan.cs @@ -0,0 +1,19 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(16)] + public class M0016_AddingUnifiedPlan : Migration + { + public override void Up() + { + + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0017_AddingToAuditTable.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0017_AddingToAuditTable.cs new file mode 100644 index 00000000..1b1660b8 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0017_AddingToAuditTable.cs @@ -0,0 +1,23 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(17)] + public class M0017_AddingToAuditTable : Migration + { + public override void Up() + { + Alter.Table("AuditLogs").AddColumn("IpAddress").AsCustom("citext").Nullable(); + Alter.Table("AuditLogs").AddColumn("Successful").AsBoolean().Nullable(); + Alter.Table("AuditLogs").AddColumn("ObjectId").AsCustom("citext").Nullable(); + Alter.Table("AuditLogs").AddColumn("ObjectDepartmentId").AsInt32().Nullable(); + Alter.Table("AuditLogs").AddColumn("UserAgent").AsCustom("citext").Nullable(); + Alter.Table("AuditLogs").AddColumn("ServerName").AsCustom("citext").Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0018_AddingToCallNotesAndFiles.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0018_AddingToCallNotesAndFiles.cs new file mode 100644 index 00000000..ef99f3ed --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0018_AddingToCallNotesAndFiles.cs @@ -0,0 +1,37 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(18)] + public class M0018_AddingToCallNotesAndFiles : Migration + { + public override void Up() + { + Alter.Table("CallAttachments").AddColumn("IsDeleted").AsBoolean().NotNullable().WithDefaultValue(false); + Alter.Table("CallAttachments").AddColumn("IsFlagged").AsBoolean().NotNullable().WithDefaultValue(false); + Alter.Table("CallAttachments").AddColumn("FlaggedReason").AsCustom("citext").Nullable(); + Alter.Table("CallAttachments").AddColumn("FlaggedByUserId").AsCustom("citext").Nullable(); + Alter.Table("CallAttachments").AddColumn("DeletedByUserId").AsCustom("citext").Nullable(); + Alter.Table("CallAttachments").AddColumn("FlaggedOn").AsDateTime2().Nullable(); + Alter.Table("CallAttachments").AddColumn("DeletedOn").AsDateTime2().Nullable(); + + Alter.Table("CallNotes").AddColumn("IsDeleted").AsBoolean().NotNullable().WithDefaultValue(false); + Alter.Table("CallNotes").AddColumn("IsFlagged").AsBoolean().NotNullable().WithDefaultValue(false); + Alter.Table("CallNotes").AddColumn("FlaggedReason").AsCustom("citext").Nullable(); + Alter.Table("CallNotes").AddColumn("FlaggedByUserId").AsCustom("citext").Nullable(); + Alter.Table("CallNotes").AddColumn("DeletedByUserId").AsCustom("citext").Nullable(); + Alter.Table("CallNotes").AddColumn("FlaggedOn").AsDateTime2().Nullable(); + Alter.Table("CallNotes").AddColumn("DeletedOn").AsDateTime2().Nullable(); + + Alter.Table("CallDispatches").AddColumn("DispatchedOn").AsDateTime2().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime); ; + Alter.Table("CallDispatchGroups").AddColumn("DispatchedOn").AsDateTime2().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime); ; + Alter.Table("CallDispatchRoles").AddColumn("DispatchedOn").AsDateTime2().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime); ; + Alter.Table("CallDispatchUnits").AddColumn("DispatchedOn").AsDateTime2().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime); ; + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0019_AddingDeleteReasonToCalls.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0019_AddingDeleteReasonToCalls.cs new file mode 100644 index 00000000..0e6193c3 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0019_AddingDeleteReasonToCalls.cs @@ -0,0 +1,20 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(19)] + public class M0019_AddingDeleteReasonToCalls : Migration + { + public override void Up() + { + Alter.Table("Calls").AddColumn("DeletedReason").AsCustom("citext").Nullable(); + Alter.Table("Calls").AddColumn("DeletedByUserId").AsCustom("citext").Nullable(); + Alter.Table("Calls").AddColumn("DeletedOn").AsDateTime2().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0020_AddingLangToUPAndSystemQ.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0020_AddingLangToUPAndSystemQ.cs new file mode 100644 index 00000000..a9b448c9 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0020_AddingLangToUPAndSystemQ.cs @@ -0,0 +1,26 @@ +using FluentMigrator; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(20)] + public class M0020_AddingLangToUPAndSystemQ : Migration + { + public override void Up() + { + // Adding Language to User Profile + Alter.Table("UserProfiles").AddColumn("Language").AsCustom("citext").Nullable(); + + // Updating Queue Item to handle System Queue stuff (i.e. Delete Account and Department requests) + Alter.Table("QueueItems").AddColumn("ToBeCompletedOn").AsDateTime2().Nullable(); + Alter.Table("QueueItems").AddColumn("Reason").AsCustom("citext").Nullable(); + Alter.Table("QueueItems").AddColumn("QueuedByUserId").AsCustom("citext").Nullable(); + Alter.Table("QueueItems").AddColumn("Data").AsCustom("citext").Nullable(); + Alter.Table("QueueItems").AddColumn("ReminderCount").AsInt32().Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0021_AddingCallReferences.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0021_AddingCallReferences.cs new file mode 100644 index 00000000..2ed16d53 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0021_AddingCallReferences.cs @@ -0,0 +1,33 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(21)] + public class M0021_AddingCallReferences : Migration + { + public override void Up() + { + Create.Table("CallReferences") + .WithColumn("CallReferenceId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("SourceCallId").AsInt32().NotNullable() + .WithColumn("TargetCallId").AsInt32().NotNullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable() + .WithColumn("AddedByUserId").AsCustom("citext").NotNullable() + .WithColumn("Note").AsCustom("citext").Nullable(); + + Create.ForeignKey("FK_CallReferences_Call_Source") + .FromTable("CallReferences").ForeignColumn("SourceCallId") + .ToTable("Calls").PrimaryColumn("CallId"); + + Create.ForeignKey("FK_CallReferences_Call_Target") + .FromTable("CallReferences").ForeignColumn("TargetCallId") + .ToTable("Calls").PrimaryColumn("CallId"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0022_AddingQuantityForPlanAddon.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0022_AddingQuantityForPlanAddon.cs new file mode 100644 index 00000000..38423baf --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0022_AddingQuantityForPlanAddon.cs @@ -0,0 +1,19 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(22)] + public class M0022_AddingQuantityForPlanAddon : Migration + { + public override void Up() + { + Alter.Table("PaymentAddons").AddColumn("Quantity").AsInt64().NotNullable().WithDefaultValue(1); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0023_AddingPlanAddonFor10Pack.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0023_AddingPlanAddonFor10Pack.cs new file mode 100644 index 00000000..fd6dd08a --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0023_AddingPlanAddonFor10Pack.cs @@ -0,0 +1,26 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(23)] + public class M0023_AddingPlanAddonFor10Pack : Migration + { + public override void Up() + { + if (Schema.Table("PlanAddons").Constraint("FK_PlanAddons_Plans").Exists()) + { + Delete.ForeignKey("FK_PlanAddons_Plans").OnTable("PlanAddons"); + } + + Alter.Table("PlanAddons").AlterColumn("PlanId").AsInt32().Nullable(); + Alter.Table("PlanAddons").AddColumn("TestExternalId").AsCustom("citext").Nullable(); + Insert.IntoTable("PlanAddons").Row(new { PlanAddonId = "6f4c5f8b-584d-4291-8a7d-29bf97ae6aa9", AddonType = 1, Cost = 35, ExternalId = "price_0N7MM5qJFDZJcnkVZy4Z51IC", TestExternalId = "price_0NLHvaqJFDZJcnkVS3DHnRA8" }); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0024_AddingDepartmentAudio.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0024_AddingDepartmentAudio.cs new file mode 100644 index 00000000..302def37 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0024_AddingDepartmentAudio.cs @@ -0,0 +1,30 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(24)] + public class M0024_AddingDepartmentAudio : Migration + { + public override void Up() + { + Create.Table("DepartmentAudios") + .WithColumn("DepartmentAudioId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("DepartmentAudioType").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext").Nullable() + .WithColumn("Data").AsCustom("citext").Nullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable() + .WithColumn("AddedByUserId").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_DepartmentAudios_Department") + .FromTable("DepartmentAudios").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0025_AddingTypeToDepartmentAudio.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0025_AddingTypeToDepartmentAudio.cs new file mode 100644 index 00000000..375a54a8 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0025_AddingTypeToDepartmentAudio.cs @@ -0,0 +1,19 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(25)] + public class M0025_AddingTypeToDepartmentAudio : Migration + { + public override void Up() + { + Alter.Table("DepartmentAudios").AddColumn("Type").AsCustom("citext").Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0026_AddingEntityPlan.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0026_AddingEntityPlan.cs new file mode 100644 index 00000000..6b360a09 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0026_AddingEntityPlan.cs @@ -0,0 +1,30 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(26)] + public class M0026_AddingEntityPlan : Migration + { + public override void Up() + { + Alter.Table("Plans").AddColumn("TestExternalId").AsCustom("citext").Nullable(); + Alter.Table("Payments").AddColumn("Quantity").AsInt64().NotNullable().WithDefaultValue(1); + + Insert.IntoTable("Plans").Row(new { PlanId = 36, Name = "Entity", Cost = 0, Frequency = 3, ExternalId = "price_0OLxxPqJFDZJcnkVDRHyMUYb", TestExternalId = "price_0OJ0FsqJFDZJcnkVfE87UKr6" }); + Insert.IntoTable("Plans").Row(new { PlanId = 37, Name = "Entity Monthly", Cost = 0, Frequency = 2, ExternalId = "price_0OLxxPqJFDZJcnkVfJLISCp4", TestExternalId = "price_0OIzLPqJFDZJcnkVRn2tpwFF" }); + + + Insert.IntoTable("PlanLimits").Row(new { PlanId = 36, LimitType = 6, LimitValue = 10 }); // Entities Per Pack + Insert.IntoTable("PlanLimits").Row(new { PlanId = 37, LimitType = 6, LimitValue = 10 }); // Entities Per Pack + + Insert.IntoTable("PlanAddons").Row(new { PlanAddonId = "04b6db64-7dbf-4b3d-a1d1-60bffde004b4", PlanId = 36, AddonType = 1, Cost = 30000, ExternalId = "price_0NMZrMqJFDZJcnkVTpb07W60", TestExternalId = "price_0NLHvaqJFDZJcnkVS3DHnRA8" }); + Insert.IntoTable("PlanAddons").Row(new { PlanAddonId = "8f730f54-2574-445e-875a-5819f8bcda7a", PlanId = 37, AddonType = 1, Cost = 3000, ExternalId = "price_0NMZrMqJFDZJcnkVTpb07W60", TestExternalId = "price_0NLHvaqJFDZJcnkVS3DHnRA8" }); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0027_AddingFreeEntityLimits.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0027_AddingFreeEntityLimits.cs new file mode 100644 index 00000000..38c0638f --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0027_AddingFreeEntityLimits.cs @@ -0,0 +1,19 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(27)] + public class M0027_AddingFreeEntityLimits : Migration + { + public override void Up() + { + Insert.IntoTable("PlanLimits").Row(new { PlanId = 1, LimitType = 6, LimitValue = 10 }); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0028_AddingDeletedWorkshiftColumns.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0028_AddingDeletedWorkshiftColumns.cs new file mode 100644 index 00000000..73d8b337 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0028_AddingDeletedWorkshiftColumns.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(28)] + public class M0028_AddingDeletedWorkshiftColumns : Migration + { + public override void Up() + { + Alter.Table("Workshifts").AddColumn("DeletedOn").AsDateTime2().Nullable(); + Alter.Table("Workshifts").AddColumn("DeletedById").AsCustom("citext").Nullable(); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0029_AddingCustomStateDetailColumns.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0029_AddingCustomStateDetailColumns.cs new file mode 100644 index 00000000..7f824d1e --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0029_AddingCustomStateDetailColumns.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(29)] + public class M0029_AddingCustomStateDetailColumns : Migration + { + public override void Up() + { + Alter.Table("CustomStateDetails").AddColumn("BaseType").AsInt32().NotNullable().WithDefaultValue(-1); + Alter.Table("CustomStateDetails").AddColumn("TTL").AsInt32().NotNullable().WithDefaultValue(0); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0030_AddingDocumentCategories.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0030_AddingDocumentCategories.cs new file mode 100644 index 00000000..aa72498a --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0030_AddingDocumentCategories.cs @@ -0,0 +1,28 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(30)] + public class M0030_AddingDocumentCategories : Migration + { + public override void Up() + { + Create.Table("DocumentCategories") + .WithColumn("DocumentCategoryId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext").NotNullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable() + .WithColumn("AddedById").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_DocumentCategories_Department") + .FromTable("DocumentCategories").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0031_AddingNoteCategories.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0031_AddingNoteCategories.cs new file mode 100644 index 00000000..7e50adc0 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0031_AddingNoteCategories.cs @@ -0,0 +1,28 @@ +using FluentMigrator; +using System; + +namespace Resgrid.Providers.MigrationsPg.Migrations +{ + [Migration(31)] + public class M0031_AddingNoteCategories : Migration + { + public override void Up() + { + Create.Table("NoteCategories") + .WithColumn("NoteCategoryId").AsCustom("citext").NotNullable().PrimaryKey() + .WithColumn("DepartmentId").AsInt32().NotNullable() + .WithColumn("Name").AsCustom("citext").NotNullable() + .WithColumn("AddedOn").AsDateTime2().NotNullable() + .WithColumn("AddedById").AsCustom("citext").NotNullable(); + + Create.ForeignKey("FK_NoteCategories_Department") + .FromTable("NoteCategories").ForeignColumn("DepartmentId") + .ToTable("Departments").PrimaryColumn("DepartmentId"); + } + + public override void Down() + { + + } + } +} diff --git a/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj b/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj new file mode 100644 index 00000000..2160d81e --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Resgrid.Providers.MigrationsPg.csproj @@ -0,0 +1,32 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + + + Never + + + + + + + + + + + + + diff --git a/Providers/Resgrid.Providers.MigrationsPg/Sql/EF0001_PopulateOIDCDb.sql b/Providers/Resgrid.Providers.MigrationsPg/Sql/EF0001_PopulateOIDCDb.sql new file mode 100644 index 00000000..a0fcaec0 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Sql/EF0001_PopulateOIDCDb.sql @@ -0,0 +1,343 @@ +DO $$ BEGIN + IF EXISTS(SELECT migrationid FROM public.__efmigrationshistory WHERE migrationid = '20210904153137_CreateOpenIddictModels') THEN + + -- + -- CREATE TABLE IF NOT EXISTS "public"."__efmigrationshistory" + -- + CREATE TABLE IF NOT EXISTS public.__efmigrationshistory( + migrationid character varying(150) NOT NULL, + productversion character varying(32) NOT NULL + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = '__efmigrationshistory' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.__efmigrationshistory + ADD PRIMARY KEY (migrationid); +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."openiddictscopes" + -- + CREATE TABLE IF NOT EXISTS public.openiddictscopes( + id uuid NOT NULL, + concurrencytoken character varying(50), + description character varying, + descriptions character varying, + displayname character varying, + displaynames character varying, + name character varying(200), + properties character varying, + resources character varying + ); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddictscopes' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.openiddictscopes + ADD PRIMARY KEY (id); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddictscopes' and constraint_type = 'UNIQUE') then + ALTER TABLE public.openiddictscopes + ADD CONSTRAINT openiddictscopes_name_key UNIQUE(name); +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."openiddictapplications" + -- + CREATE TABLE IF NOT EXISTS public.openiddictapplications( + id uuid NOT NULL, + clientid character varying(100), + clientsecret character varying, + concurrencytoken character varying(50), + consenttype character varying(50), + displayname character varying, + displaynames character varying, + permissions character varying, + postlogoutredirecturis character varying, + properties character varying, + redirecturis character varying, + requirements character varying, + clienttype character varying(50), + applicationtype character varying, + jsonwebkeyset character varying, + settings character varying + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddictapplications' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.openiddictapplications + ADD PRIMARY KEY (id); +END IF; + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddictapplications' and constraint_type = 'UNIQUE') then + ALTER TABLE public.openiddictapplications + ADD CONSTRAINT openiddictapplications_clientid_key UNIQUE(clientid); +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."openiddictauthorizations" + -- + CREATE TABLE IF NOT EXISTS public.openiddictauthorizations( + id uuid NOT NULL, + applicationid uuid, + concurrencytoken character varying(50), + creationdate timestamp without time zone, + properties character varying, + scopes character varying, + status character varying(50), + subject character varying(400), + type character varying(50) + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddictauthorizations' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.openiddictauthorizations + ADD PRIMARY KEY (id); +END IF; + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddictauthorizations' and constraint_type = 'FOREIGN KEY') then + ALTER TABLE public.openiddictauthorizations + ADD CONSTRAINT fk_openiddictauthorizations_openiddictapplications_applicationi FOREIGN KEY (applicationid) + REFERENCES public.openiddictapplications(id) ON DELETE NO ACTION ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + -- + -- CREATE TABLE IF NOT EXISTS "public"."openiddicttokens" + -- + CREATE TABLE IF NOT EXISTS public.openiddicttokens( + id uuid NOT NULL, + applicationid uuid, + authorizationid uuid, + concurrencytoken character varying(50), + creationdate timestamp without time zone, + expirationdate timestamp without time zone, + payload character varying, + properties character varying, + redemptiondate timestamp without time zone, + referenceid character varying(100), + status character varying(50), + subject character varying(400), + type character varying(50) + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddicttokens' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.openiddicttokens + ADD PRIMARY KEY (id); +END IF; + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddicttokens' and constraint_type = 'UNIQUE') then + ALTER TABLE public.openiddicttokens + ADD CONSTRAINT openiddicttokens_referenceid_key UNIQUE(referenceid); +END IF; + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddicttokens' and constraint_type = 'FOREIGN KEY' and constraint_name = 'fk_openiddicttokens_openiddictapplications_applicationid') then + ALTER TABLE public.openiddicttokens + ADD CONSTRAINT fk_openiddicttokens_openiddictapplications_applicationid FOREIGN KEY (applicationid) + REFERENCES public.openiddictapplications(id) ON DELETE NO ACTION ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'openiddicttokens' and constraint_type = 'FOREIGN KEY' and constraint_name = 'fk_openiddicttokens_openiddictauthorizations_authorizationid') then + ALTER TABLE public.openiddicttokens + ADD CONSTRAINT fk_openiddicttokens_openiddictauthorizations_authorizationid FOREIGN KEY (authorizationid) + REFERENCES public.openiddictauthorizations(id) ON DELETE NO ACTION ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetusers" + -- + CREATE TABLE IF NOT EXISTS public.aspnetusers( + id character varying(450) NOT NULL, + username character varying(256), + normalizedusername character varying(256), + email character varying(256), + normalizedemail character varying(256), + emailconfirmed boolean NOT NULL, + passwordhash character varying, + securitystamp character varying, + concurrencystamp character varying, + phonenumber character varying, + phonenumberconfirmed boolean NOT NULL, + twofactorenabled boolean NOT NULL, + lockoutend timestamp with time zone, + lockoutenabled boolean NOT NULL, + accessfailedcount integer NOT NULL + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetusers' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetusers + ADD PRIMARY KEY (id); +END IF; + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetusers' and constraint_type = 'UNIQUE') then + ALTER TABLE public.aspnetusers + ADD CONSTRAINT aspnetusers_normalizedusername_key UNIQUE(normalizedusername); +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetusertokens" + -- + CREATE TABLE IF NOT EXISTS public.aspnetusertokens( + userid character varying(450) NOT NULL, + loginprovider character varying(450) NOT NULL, + name character varying(450) NOT NULL, + value character varying + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetusertokens' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetusertokens + ADD PRIMARY KEY (userid, loginprovider, name); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetusertokens' and constraint_type = 'FOREIGN KEY') then + ALTER TABLE public.aspnetusertokens + ADD CONSTRAINT fk_aspnetusertokens_aspnetusers_userid FOREIGN KEY (userid) + REFERENCES public.aspnetusers(id) ON DELETE CASCADE ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetuserlogins" + -- + CREATE TABLE IF NOT EXISTS public.aspnetuserlogins( + loginprovider character varying(450) NOT NULL, + providerkey character varying(450) NOT NULL, + providerdisplayname character varying, + userid character varying(450) NOT NULL + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserlogins' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetuserlogins + ADD PRIMARY KEY (loginprovider, providerkey); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserlogins' and constraint_type = 'FOREIGN KEY') then + ALTER TABLE public.aspnetuserlogins + ADD CONSTRAINT fk_aspnetuserlogins_aspnetusers_userid FOREIGN KEY (userid) + REFERENCES public.aspnetusers(id) ON DELETE CASCADE ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetuserclaims" + -- + CREATE TABLE IF NOT EXISTS public.aspnetuserclaims( + id serial, + userid character varying(450) NOT NULL, + claimtype character varying, + claimvalue character varying + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserclaims' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetuserclaims + ADD PRIMARY KEY (id); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserclaims' and constraint_type = 'FOREIGN KEY') then + ALTER TABLE public.aspnetuserclaims + ADD CONSTRAINT fk_aspnetuserclaims_aspnetusers_userid FOREIGN KEY (userid) + REFERENCES public.aspnetusers(id) ON DELETE CASCADE ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetroles" + -- + CREATE TABLE IF NOT EXISTS public.aspnetroles( + id character varying(450) NOT NULL, + name character varying(256), + normalizedname character varying(256), + concurrencystamp character varying + ); + + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetroles' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetroles + ADD PRIMARY KEY (id); +END IF; + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetroles' and constraint_type = 'UNIQUE') then + ALTER TABLE public.aspnetroles + ADD CONSTRAINT aspnetroles_normalizedname_key UNIQUE(normalizedname); +END IF; + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetuserroles" + -- + CREATE TABLE IF NOT EXISTS public.aspnetuserroles( + userid character varying(450) NOT NULL, + roleid character varying(450) NOT NULL + ); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserroles' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetuserroles + ADD PRIMARY KEY (userid, roleid); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserroles' and constraint_type = 'FOREIGN KEY' and constraint_name = 'fk_aspnetuserroles_aspnetroles_roleid') then + ALTER TABLE public.aspnetuserroles + ADD CONSTRAINT fk_aspnetuserroles_aspnetroles_roleid FOREIGN KEY (roleid) + REFERENCES public.aspnetroles(id) ON DELETE CASCADE ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetuserroles' and constraint_type = 'FOREIGN KEY' and constraint_name = 'fk_aspnetuserroles_aspnetusers_userid') then + ALTER TABLE public.aspnetuserroles + ADD CONSTRAINT fk_aspnetuserroles_aspnetusers_userid FOREIGN KEY (userid) + REFERENCES public.aspnetusers(id) ON DELETE CASCADE ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + + -- + -- CREATE TABLE IF NOT EXISTS "public"."aspnetroleclaims" + -- + CREATE TABLE IF NOT EXISTS public.aspnetroleclaims( + id serial, + roleid character varying(450) NOT NULL, + claimtype character varying, + claimvalue character varying + ); + + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetroleclaims' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.aspnetroleclaims + ADD PRIMARY KEY (id); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'aspnetroleclaims' and constraint_type = 'FOREIGN KEY') then + ALTER TABLE public.aspnetroleclaims + ADD CONSTRAINT fk_aspnetroleclaims_aspnetroles_roleid FOREIGN KEY (roleid) + REFERENCES public.aspnetroles(id) ON DELETE CASCADE ON UPDATE NO ACTION INITIALLY IMMEDIATE; +END IF; + + + + INSERT INTO public.__efmigrationshistory (migrationid, productversion) + SELECT '20210904153137_CreateOpenIddictModels' AS migrationid,'5.0.9' AS productversion FROM public.__efmigrationshistory + WHERE NOT EXISTS( + SELECT migrationid FROM public.__efmigrationshistory WHERE migrationid = '20210904153137_CreateOpenIddictModels' + ) + LIMIT 1; + + INSERT INTO public.__efmigrationshistory (migrationid, productversion) + SELECT '20240412153137_UpdateOpenIddictModelsToV5' AS migrationid,'5.0.9' AS productversion FROM public.__efmigrationshistory + WHERE NOT EXISTS( + SELECT migrationid FROM public.__efmigrationshistory WHERE migrationid = '20240412153137_UpdateOpenIddictModelsToV5' + ) + LIMIT 1; + + END IF; +END $$; diff --git a/Providers/Resgrid.Providers.MigrationsPg/Sql/EF0003_PopulateDocDb.sql b/Providers/Resgrid.Providers.MigrationsPg/Sql/EF0003_PopulateDocDb.sql new file mode 100644 index 00000000..f2ac3af0 --- /dev/null +++ b/Providers/Resgrid.Providers.MigrationsPg/Sql/EF0003_PopulateDocDb.sql @@ -0,0 +1,52 @@ +DO $$ BEGIN +-- +-- CREATE TABLE IF NOT EXISTS "public"."unitlocations" +-- +CREATE TABLE IF NOT EXISTS public.unitlocations( + id serial, + departmentid integer, + unitid integer NOT NULL, + oid text, + "timestamp" timestamp without time zone NOT NULL DEFAULT (now() AT TIME ZONE 'utc'::text), + data jsonb NOT NULL +); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'unitlocations' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.unitlocations + ADD PRIMARY KEY (id); +END IF; + + +-- +-- CREATE TABLE IF NOT EXISTS "public"."personnellocations" +-- +CREATE TABLE IF NOT EXISTS public.personnellocations( + id serial, + departmentid integer, + userid text NOT NULL, + oid text, + "timestamp" timestamp without time zone NOT NULL DEFAULT (now() AT TIME ZONE 'utc'::text), + data jsonb NOT NULL +); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'personnellocations' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.personnellocations + ADD PRIMARY KEY (id); +END IF; + + +-- +-- CREATE TABLE IF NOT EXISTS "public"."maplayers" +-- +CREATE TABLE IF NOT EXISTS public.maplayers( + id serial, + departmentid integer, + oid text + data jsonb NOT NULL +); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'maplayers' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE public.maplayers + ADD PRIMARY KEY (id); +END IF; +END $$; diff --git a/Providers/Resgrid.Providers.MigrationsPg/Sql/M0001_InitialMigration.sql b/Providers/Resgrid.Providers.MigrationsPg/Sql/M0001_InitialMigration.sql new file mode 100644 index 0000000000000000000000000000000000000000..1d2934046c0d6a89f3758e31bc912f9d75e158c6 GIT binary patch literal 278484 zcmeHwS(9BilHPru2>*u)&V#7%Q06MK<#5DM6xF7OVz(vA9{EL4EH2IA+Et_|_K&xn z-^ofQmc)8+?>U#cQBhTQIY_U0k| zJ)*z2H{WjVPp@5SUzwCHPLz(QTwKrd&13qUYky94zuf#w^fW(nviTc*e@ee6QwvY2 z+;7t-A2-i8uQ$&&7dKZnS2wpdU(z=ZHh-a3;{VUo&if8k?c>o@4!wOg^*&eX0@e9^ z^J?M@c=U?6c!B80pB`;K(39_|wQs1u@0@3jHvgc{UK5R6O|R)09<`btU)x-se!g^i z_?T*VJ8|aS)Z*7uE5T>*Dc9el&381W-_z)VYvAAIX*9mv{MYHfD-o8Qy`}L1moQEr zsq_nK$;YXrNayW|?p>0mRw+9ABp0`-mETeMzY>*un;)pPKW=`Z_y0z1$N!57IjikO z?QB7B-)x>zk1@06&X|x|JZtW?eaH_tsviuv32gc?JjnNyD35?Q9 z`WYp)N?$0uNV~mSMAk>uz_t&N5fnd8v-{XVH_?Fa$v%5LN&1s%UWsmF+Z48CjTNc$ z?_|;i@20sgl6FS#-qRd z*Zh>qK_XiF3X2o{J?$vV5rgLxEnr-(wX|iP^vD=`i1Ic5#l?-~#iwT(&nVb9;H4ik z(KrR76E(B$2Ko4I^nk55-~^;{KEAVs(&{Vje+(l%er*~eO=mY+;w8z!vn}Wfp{p7r z-BW%xC->>HT&i9>oPI)aj>7fXW_b_(JNWox!zc1sZG{wzeCaK2b-TL!uliGi1+90q6yH;e5aGYK`7^b~jiu(xe)-APg}n<3-_tMtKcF>(yVS=c zvd?tAA=j%jirkiJJDNDhu@J03@Os1@;^I$KAMEYBR3o^1L^15Y(tBC6z={AY@;g-K z-uV;Y{JrTt;?no0=rJP7KMCu7yB;R;eRJCJehv6I)Dg7ul;RNQWTB9&Ecj# z-DBmjkBN8y<`E)9Ws5^`OzWO!Yvi!@Ew$@pT8DuD1HZZt&$ZPjG&kX)bNp_coy1W> z@bN9Rv4)dN;JJ>ON^uK<$K_ivyEMln_5nZPdH4JZsp#DDzsb!jS?R2u6?NV(qz--s z>#kSys@?mQK0t@K(bgJ?%gwYC;<>CikDkwQ?E4E^>%F-RVl2Q}4-LiDkYxJp6*@h&Ey*y8Tgi0(m z{7p_)*e=4F))T^To^Lf{okLv7WPz@kOAA&Fw+`7gy#6+qCgP!wsBO>;Y}JgRn_Bal z+ukRe->I$0of*XejmGK9&V_CpG$#xGdO1sC*%pr}E{P{Hzk0Ng&cIRYCcGjeQ5tDm zFM=RbD5T}$Nc?>cO?vFU*jMxIk60Ge=YidQI%RykqyMmC#Ea_nr*gGzd)6!?dTnISX~L<;`IzGOUk=)&7b9Dxi1?G`U;qOG_6x`dYm&ZQK~o_?E? zLbm1MoyB=hIjmCZJ(#Sek;x3Z5Hehnz$N8JTil9X;i!YtwK6p-RxhKR??qj7-lC=P zc=;C5cX^E-!}?3d+TADHBkNKcaddgjT$YG9qT~A&HAf!%$McNFcN4n5nIbWW$N;-J zqjC<0)Y5m6rLGKPiM>wG)+J&}+>;*kaI?NR7oaWzpTjfJp3K?NaXhssTh=gh?Nz>& zy&bLHx9t(b4>JIl!Pq*vYDL~Us*Dt4*1CLev^Q=SQqdXcf0LVM9E11|LJGt+Y9a)P zu5nIGPVTU}@Q4uT4dK&cqRl%SLMh5okQ`-b`)8#21t;p}u&x)VRAbfn@npl6=fcI! z^-nRxax0Np+Mf%Qqc3=abvn)iuZv}AubBek@<7v3yu|ndnRS(~Jht&Fg|)*0?S;(D z;i&fhjK&*&5Z05CcZ~QV_Q>Ir7}esDsB5#LY{@o_>0Ng6pW!iKq``wZ{a*r|eavaY zV8874kk*<_eGx0a#TMNZ8pqG(@VOuNVp-N%(KCCsGBp7+<4K2NiMS>(v*uY}CVrjhA%l(gg7GN(_@Mpp%UaLI<7r{Z z@-sh{?>SfyQ)@woQGT&MI&qt<9@cruWyVgHw5bx?H~9%l2u)*Y-c* z@v}W{D+g_fT($Md4QD?3oV4UHlz~`E7+caY7QYT2EuaeW7i)7EeH!~I1EpLlUh!g^ z9P79J`4<)?wH|o9#QRC@X4vieX`7CQkAOH7vbf8hm+D03i<~`CF1dv6v&ODv1%c<+ zn5e>kkgbAzfzzoo3V z>OAOOc~$DL5o~MFQF%`E%KkkJ6@YZS@^TtXrFL_>*hWA;YlyOyk26) zik!F1Qk@C4D>5bR0jWnkigzIU`f`5MzLvVq^|}%{Eb#l#hY9d@d6)JfUSHOCiVN$E z*VoCE-t{(8q?9)7k-zUXWWXO`GrVF-?>*RX|3@nE!nc7 zrKNmS>9rr{MU$7%QlUh&&62S6*!l33_E+#}HXKLqpAj)7cTR-g=4Qn)waIT)|Cu{6 zEo4)1oUjFzmpuukS4j#~O4ySb40_HnXQEfi^|$vKjI3SLWl&-m8-{u!;;}pw+^L<2oA`4EndS%Y3By#jo>frd-o)( zHlD!F{hh`GQlY0*fy-@lde5Lhy;_#>sGlq1KlPoV_c`zI3MG~$PWZ*XYx}uO*67XC z)jCgnOXWSyT}Y{Z@6MyTIT)|Eq}H!xeuC~CPAy}3gqpO~_6W<5wLV;|>W{hlmA(mw>sP>uT){)MLL6*_dUiddMcebeF-*x4T{QsxB7E^%X*V{XXYtl&6a2WOVXzG z7Lw3*d&`j!?4Fq4=VfM%D+!RNmiUq{jU(raWv%tv>ozT&H`e#L+0(MKp)TvJO$x7j zdynBSphd7Q=VeLd<~2^FeM9G);)F4tHSlo5h;NRB z|L2u5ZOJG<7BY+dZLnsr4#^T&n=J}$=kM_cjjNPjiJ5?%z9K2%EYO~So3BY4TITl> zTEH5kHcenrXwe6wG8e3NSUsuBa3a#R z2{~-d&h$D;SeoU!E)QW8#)NIKdQgWiF(t(oOS*tB*5}|t9%WLc+Ofu>1TWP3oJYq- zoqagl4SpR?z{mbk*w(#>6Vp+|3BO|m*&gEfb~sKm_ajbaOEZUOExu8X4y0-P2_qq| zfsEMeU4y>4)?&XiWaJg`66gQH-hojZjrifSjOMl{W{pP} zThHNaSXYh3y#~uMY_~Nl>v1Newg$Wj+hp~y4|ih92mD#;)c$b(hGWAg=D~i!EskTX z&U_v9xa7921*5|Hxoo|)>egF>SH7Kv6+t;@1v=uQqvmbrN&GM~z+q(0_x^q-$x2zzp0avXtuu!EQPc4dTz)`DRR!{rz)25!r zO$#T%r8b;ozRtx(3kR9<{^B08jd1g5Kf1XT6vOmWaOjAzQ}%+qbh5(x5C-utthBXR zbBGbTH_s{pwb+t;`#A1s6Rprg2R*>f!q$Boyk;Xe9`~;g<$QdtLsp8~_?%i%FUJ|; zjDPpEHtd}N&pyzK9rEMQI(!Cf@-1_<;9wmx=!=BG*rJ>()l^%r|ipGnL9eLvw0WGoNSdGMN2O+ z&S||lJ!MG^Kkv`*Jg$nS?Jo)2dON7!cd{SnOklOFCnKkBT~Ot_365VopME94&$3|2S@fhGQcH`mo1@hB%Z{7vELH>fnLs)g3e>@*I zTv`@(==a;f56R47>htp9mbFTiQTfWJOCoAf zccTGr2YN+6h;Fy;!+%5CmZR3Hi{o=+KTKoI5o+uo(g?qv8<4)A61TY^)+6yAE#J16 zBqxnnRl%vZ?imTa^{9-WkbL9x6tsLEe_WavSs)tja_V2na%o`vdu9-B^gxypuZTbf zF(SAdSMSemodfPjfP1)A3i85HxU!X_oB}R^Ka3YZuf7#LoU_R1)pAQt&d(sk>^z|# zzAKyS0h;-%LOH2Jjz0DpKcZipegISsS8w9-`SmL7!Nkl*OVEEkGoqCewBYjzLtazs zxbJ$G3bOxmH_qxf_;g}iDp6X(Hce}0%dSgXsA)P&*s1B(SiP#VR&zAfX0>dV!}=HB zdU9{`fb7|alTCY{ZYKSOX727SU7!z66Ycej({iAc>nvYxN6rGy)rG8&67DHBg_PRt zHI5{-)CVi;_ofz((qg`@7MrS7JA+@E*&w+nbyU`c<0_RcQOHnU)Ke6C>%w(u)i&^5 zX)DgB`2)01e+#bVW1IQ1?dv0HdRQ+>f6L>$zw0M#AHJA@^RO>b-bHi%EQi^a1;EeO zqjkTxgWB7$9q}M!dtp}#tl+=V>lUQv>~_@KO96f~-zo^7;^U;BkDV;Wwrsv-&{t%o z4P#ZBb{)yp*%7z6)*hBVD=J#D|2bK|`*1puH3qO>B=XT~_m=4@PL`hCHhzv=F;W{E zF$`U)2;(3AbB_s2@ied2#dkCNPa|6b(NshjOLTFPCL%R2C!8+DVB#2xb;>ulm19}B z+b(QFO++O{7rjFC8{SULhhEBpUzTQFLIac}-m**6(UcN3^m^ACqtqs=hjp5yOj$LI zj5}M|sy|CMwLaNnL5rq?z3fu5t>d-i2#?AJDUVOB4Z-)mmg!-<XXz3E%`)o_M`SSBu720lYH$g6e2pVaD3dKd4-JL}Gj7@@5Hr?Mt7f zyVBa(FS~>;_FG`JzE1OobX3n;b1sL!dHriqJ0Nf=TZczy9`d@;E2fu2T3;Uc$@-`j zRj1oc}B>LLH?jc(Y5wcPl2N&_OIh6 zsvFbo961zV3kqi_Kc|sZ3#x3vUEExoZo2aC|43=JeX@j7BV*0(92TYM@SLg3U>)VN z=A^RLTfIP$winac`hrlY9=bSYNyNc&LZ-(WvOnNq;^ZM%HT@^|r&mow`ig+HWpa3E z$re9fZ>9C+;;B`}r{TUK9->Fc3Vgmn%vdu7fEy)`ROyNS(X4C4iIIo+bc%9w*0oDr zN?1Kty2vv`-U?1$fu*fG(GiVCixEKwUAGtRdG2mTW?P^9zKp8BevBa}x=N6iJb3(w zjPPAst*a(3ufwcK&Q=Fr;^r{-$=F9oJ# z`%h|kxP)Jpo;@Mf$96^9TB@bGgzZ$@Hp@P&^Zx2#4;cG3NAzx6=i`pD zzU#*~o-^B%pqx*DoIUn~ecdf~NIvqAFZ+`44*MQlw38A%zuTh}X-@Ox^Jy+iJJ>$8*R;~5xm3Na=hs#f$GAd~l3SENP>PetIdGEw zT-UPotnidaGe)1Z#!iozI|94T$|$$0UrX1}R{flQ8qtsRw~(qly5`Ha=X0d#alAJr zH)ttl4ew_8j&^0=r(f*O#yJhQH$P2(@wq(n^JbUYyB#^<5%Ecn&``d=J1QESt0RY| z>2i!iHm+J;S{-hw2kFk|8n2}8oVAt=gd8&W?*s4kR$_IV z2+t3?gySK#H{&Ty(83;Ej^1z_YCcuuK4NFM?z(R2CtG%iDRQ1n8<(VXi)<)Ac&{}^ zMziLZ@Q`CXP0w9R8@1@%G-XETrB@l!?X!Ab=j*ibS2ePQg@=`h-L6FN*dY$hCtD-x zHP1f@X@xq}|9;!L((0dLVZ9f_r##5%2leF?16xqrJ^g~uR&B#=zdXjYR}aOSKK7r! z*j(A%q_yp9bRyVgdd+{2rq$?goWEaezM-GFT9(hEctLdDP~;nN3iP(Tq7%1UcLXe_ zmHgRYVQ@+N_!O4YGJZR(p0sF_klI0OtjklwIn)w&>DL!N6<1TZ-)vt;Ad?R_p|_n` zfd0Ru{iwK&qMT2ob}@79%>(W19yZC2-X z^6p&N9Il4tkto-pEry50X8^&D;g$Io&i3hPj3l%V^bmI5joX<9TDY;KJr7KIf;D!m zEbG3xvGNjY)ZJPFI3fXW%c`!K=BgU3zs05o}I%==nAT*i)d<=wLTau%#x7QNj4 z`h?p8tM#>3t54^TW3R4dU3OG%fREqXkchB`P-leiF)vChP_Fb@<$G44T$;S{=j&sItsa)vj+k2g8P0J`Pbncg^)cDAH6C7$ z4m=}0iv$+h%ZX}z-gWOj$SJgM7iah-jt6#h7t=|1QyXb0?gK|Xx1&hlxf-f}s!mxiEr*Vl6j+E;!b*$Ia>!}5#_ClIj@mT;IHhS1{KG4FT((_b{tHCT;4=t(DR(XsmVX%9dv4>bDoDyJh6P|JQI>x^E7Kk>VkOhjK0UvucVoXOhWB46o@b=a?TC`m* z($gQg9^otK$_7WjTh}%${hRA;Yow+wlC`Z>4YefTJ0VAl&)@0KLRX4?_KqN7i}Wqw z&xNzm(%ormBP_jy)e*MA>Or0Ei76edkX>3KrN|fGAi;Uek4Q_weup)WbFHvC*srZL zKia12YOnmW`=ZUzi_(o8IsE|t3p{VZw~Nzhl>TXvayC;KdsF;nO@tilm*f%ptNGzm zr;Y8wxeqre15oK8Qwnu`p#I?`rkXe$>pq_ja$CS3_?F0re$nmCYTGbo*g=GoQzT00 z^CLH6SaZkTrPIJ}t?l9EXe~g%3FYhOE3y_;u84S+`tXv_^b$`D!6SKi0XF*NA&= z`>dXi!9c$j7Z3At%6Yr-Gx?}j$zJAhfE>2n_!GCox59DzPyQLM*^ZU%!-^6254Iv( zcyA}m3M;vsLpskB$vN8Q$PRpl}!P0Lf&7P*VoHkFl$?9Q?2G3D;wRU{|HEZhlb8xAot?g3nD^=Fc z5Uf{OpXW63{;XO7>(gV#5yNNa`4HRE&0#I|n%Xa!*W3A?a@l%+CKY?h;rFP07>eFl zYkW*2I7go;HP~W^3*#^PmyRrAMGt$$l?!FNL+e3yP3t-OYt#n5^jXN+uN!>Yj5WL6 z$5OJ?{T5oiAEP(IdR#4%pVR95xd>O%C3%`W5`CVZ+X~;NWgSyf^XKdN{hcgOKF^ca zrnaSR;(F@!O;~o98Yir~#{XF(YKHx=kfR?rL+Wcp&ajOZ2gYD$T+=-CJYeTTx_gYz z?B3-aWF=i3jx(Q50B;_*DfaEIpI2u;rn+sPgRdb^m{z@o@3x}`Yt_DOi=ylUM!USQ z&}tlByEW|tcDwDhII|rb_iL@kbeR+La9pTJ77>rrXqz~!rN%}M%W%s+Uz-{6Y~+5y z`^E~{yv*ag|6$ivkMmY}#^lsWOTIl^wjR%W@=6ucrF37!!^$CEBko&cWT9F=-di>B zEL~T0!)m9+i81(Y*H(|~VWeXozVmpD#`7Bd=9>2zuj7>npxgXgf~^&Zkg|)#rFJlS zrjR!-&Cl1Pt=~39&0Y#M7I++cUj}1i?)luXa3qJQC3-w-c8#BtE=9ZdI=x`>a;wYWTb`jjt?_WQ$F%LxsvcVqPh@6qGBoeIh&?D*w7!MSYTPJ5+?J5sPa1E-#G8{wZ^e;l9bJ`3rS0E@CyUq6*4U4ahtR~oQoA104{Ram zW$-5-@rj>r&yDnHpyrE4J5qNVuO%aL)Ojs6V;IkZZODh!lFuoZc0YEtl+XgYNv!eh z`Nw`OZN9R$k8LjYn)u!`wJa=Y^KsF#*m7QLi}$PT;C&VIc5W}jJ zv}&pMqY%`uN40HPzAbFcYu_?Wws6E|!k$7zEWf8;{C}{yLw|pwPjROpJY+;ez9Ow( zLLFXnDLuutf6fs}w&TDx_$J%K->{w*1oq4B7K7P`=EzIgQ_P_`JkAk!lAMv%%@HW< zP2IiuIehG~Jli=|hfkfg&GM_2zSZit(c-`;%Ok95p6zk4 zJdQTE$v#>tFFUra`1YRX6gP*x!SQL};Yh0^T}R&HNR?}~Hu!ni(7;4KEjz|-)n8A@ z_vP%wo=gzgLl6A|PU18G@V9j>5vzV||IMR==rSV3Z)r^DQNjuYPB;SoP3(oURtl^dmuu{=LrBmOKXI6^|0jNt`3ZR&B|aM-EFPBXr^b` zj#h4By+I;=)4iF@wWJ4$im4e-(-q9}6ojdaN^!ucsp8gn#@MBHexQ9l1gbWwt zxV$~Le0%Fs8L}i<$Cpnv213=$!#XQe`jVPQ+o*jlHktI@vP9aVO+tya^YW1;X^+*j z{wR`C{o~kFe}t?N9oN_w*^RVF3sNYAd6l=uYbdm59NBo>zN=y_QdGXBA&w@x@tods z9P(827P{8YHr@7Y^p*@}J|{GPCTc3usQTW|XtQiqeU@_pCAyO1Xr9iz+~}}$uT>kK z?V&ccdb$^)xmaBi{}di($&;zG7k#RIQND2O(ORre{ywagOl@Ct znHBLY`>o9~Ra!uWHDp_9i>%)D+Z!%jwNHJ7J>)LmpLU+!+x$R3cPTIa9<5zIq*u%P zEbjP?v_oCGDi@Yz=RaAaZ}T>34Fz7sugjT=%87a;O79eRsX@+S3oW;q`GkJrbp(ADJFk(cz$-i)Zz1E#l$jeGj&*r7W(%L*m zBW$yjJnVxM)N5Nj2}JK*&DT*@O0fo(dHjU1JiT%+wD=icbLI4=QV+9_a-}Xzc_SQ= zLfc=Fwt>7sllq??o$qhQO|01OtnaBnQYqo&bb^Mh2z{k&F}1u z#$c?_M#Miw>suUCJ$hlvTi{HCxOe@1)*3jUr*$8D9LM7r5NCCqI2;7;!jl(L&+5nd|*tUMb9m3+vu#0^+4Im(V5Apxs<(= z>qV>OqqJ17335S~$!qjDufNLReaE=9{B*tMl3Hq3Q7%q5X#011OQt*5TlN}r`?A)7Gr|$eM`^(up~Ev`Y21<4 zSiS1SAEjyGkVw0WNII*)l{#$l%gjM3ZIR+tNPYj2OGjlMUMZazrQ|!F^?7XKXX+8D zZB_m1=0@VK(IwGD_+!nsGKNU$C6PngVD+F4FO-sn5(jHV)+O-&i1r2Qt*`L%B)9m8 z(9&I@xIm{VT=-;l!8>_2+k+M=@qFiRwlUjx=K}**u-}M%R_yMpvw5yhw;9{_883-3 zGFm-ek&frCSNO$ZO}D-cU4+g7TUyuVTd-xsu3&fMeR?+DxXu4^4b#*Q4N4{G6ii6gAu&&-C5~lCKv3vx~f3`jHRcg&4-%n2_tR3rk=G1A?TKXzW z=@O8m^tWZX%9m}Ivot-d45hzi%-G+EtJ^cyAbi43U)(iC&DO?RAGnx0i9l)cQ%h@G z(X`-GoCly;4Q%}&A7XCigK_}b4p@t~>is|({M~e>eNT1;aP~D(Xtf{m_-u{X(l&)k zouyUN9+HlND*-(Jce^rXx5VmAJFdIjQ5?^YGO#@V1h|y96Uyb=F+EQ+m6;Y=EH<`( zZhHlGFH>%ft}RfO6)nlL4~T-;OzjEITHe>~OwAteeaQQ8`=#^v-LzhSxiG@#w&|Ai zyS4#5PHTG3YRCB^c3-%3y#;{y1D{fiXoSWkv=|W@kr~!)ZLHF2>E&D;+plw84yWp1=zrW^0gI!~Gp;*Pg7ahe9Kf0k4s8)mjd)6J0R>o6 zrAU9SJ!`ZYWE?Hs+HXAw)iqiX(l)EdW2_0Sp`-zH{)O>bSEJ<7zl2yk26KEiw=Kwp zV&5iZS!kcQ=Fiu^({Wa89T~?}PFgj!>j#w-MteI4SD$j@ZgE?fM!j!n)3vCq8z*(F zW6NbTv*a-5!e|s#j+gK>jiS#B@lfTvEA>1EW3bbYeZ{rdIJp+Pc~}0} z+9fQ;L6y0AdRlruQs%7Imi4yZ5?e0U5F@Df<@`*RxjNdXX6a$~3D$5WUCU3^Yg2cO zYCM|U9y;}Q{I!^HU;46o+2yHayVvMmmj=(XrSz-Y600|@I@G79dJ?uepAn`veCsF! zyYwA6lE*Or+4hK1sWpe}A}hPdAKUr%mQPP*#kGMBD}+Eh{La~Hr5x3nGe2_Z(z3LV ze!m^vlb^+PnrvBJq8zfYw?>mFg=O`Kw!`X4s}^yoDK6y48#*NaL|Lzt%O7-&wbygJ zSLRBc%Lgvriw7U!TtdU4tlZu1WPrg$A~E!t1GW$BJK zEhvy)vSU%>aqQQbTE8F5*3Z{2DfJOU?UTFP4<{_*=FX8moJ~Kk zU#&9W{Wf*&b|Q{$PwFx(G+L=LzP)`K+dgX~&KLP&b7garPAIxYk%!Cln*Sb6CyIRI z{QY9{4gK`(Oi><&{C`CIUHp-LKUqbPt?;bSwOBE3A9RMsc->~vSX3F`mbY%KwvDxP z>>3W*>aTR43Ev>V^Wliz-Juh7@6kEB4``0uqrdm2_qa1+-c2YaZI!x@8a@az*825S z4Q16(<)?GH$%_5(^YtE>MME{XMNJX#$p+^-L96Rc2K6<=_d{vcU43XABdfL!*^qC@ z-k3vQsl6iq6sHA4LS7Qm`_xOhjY_BQ6lk~hwePkl%d~~JX$@1Rw}fsfx60~eo&Q`z zTlGnP2G_)x^S*SRKJ&iSGs@G1kCcCcYqkCA&n@q#MjB#^ZC8?(k}r%$N&-U`Po?d%;B;NuGo8fdigJCU2USoah z>NR}Ly>xEBQ>dzzdHD&JwYGcflsSlRJ$D~Fe zm(u9*2&JVhXOibUK=ri{o5QU~$191&<;Qa_mI@!&f}YZzdc3?qI|pA(*)hVKJ|7CN-qkmWkof{5joTHL7f>3g}~i=qb%-4%v%>>1u2 zpYD#^oOG`D2!)PArlbX^`Ni)1B8mQaX zM!C|seF|Axsns7o4ed3x4^$<(p>0Q5?r|>#+)s!7i47JZ9laB;ek)W0QJ{I4=%s=j1@5VzC74VN^@;~w6@IZ?R*{S(m&|N zHR;Ba$zF!l`)Wcm%;bJwIYlk6`&xZjU9FKA9Z(EDYPcSwsM?}2a&%xzoDtF^uAsYV zYxIY_$|EP-Hahje6hBJ?5xBBcwhf#12nR zC|T9YF^*$lls`@ptQKF#9mAgTJ=#KBE+f;%O)Y=n+(UwX#oBX8N0TyT7hg(GZyRw!ndka^3rH;` ziTffBQEyplDc<1(n;H>@vZbXpx5PHI6f}8XBx9NAK}i}cODBh^C3^9e_X70tB zqZW5dJ$8{elzq13eB=g)N;X_vqQ`pksj%JVf5xL_TWp`(9_95&2{0r)wfl3@*K3iS z(k_s)MCeIweL2i6HMHn(X&38O+j}V2&82C z>>jPdjc3(ZOBOPfETR%!9tX%^%ZbreOE42%uMN?zy4r0!YCj@hr5?&?3vOy`YulPJ zuCYf`hE(QhPT@wY2DMvJ(p~FD*04_&=FIUZh1X#{>qg$NwH8-KBXL}33o;9z=OVGt z*%l%TefDQ-af@5CUW6WX%5_;+3IAeg*2x!M(>OS2%4%%##A|KO1t@5>3M94rTWwY}Ds%1O)iZHQd$ zDy#XY-WIHgbm>0XOw)rbroZLd)@!wnvoYkfneAH?T2qhxAf+)fySEmsl_PCY>f9=B z>wa4j(o0Jlj<6eqKF_$dS_#rhiwmP|0b-`)pNk7E8aaAmv>PfIkCoQhMFuHa}m|t?KV% zeO2~;qtr8sE6MtO%Z}<>=1GcLPs>_;Y0du~wGr)pLp!V`!)flG71;H%HEyhxjy4GGd-K)Bek$JzSjN?Z8P?w@ZLwP(=!Ll>*+B~Ywse~|KCp8 zM74X;wOy=z-_rgoIXkF#RB+b(<4H!aKfY~5(QZC337i3kkS(j{BDY9~d*e-f*IAho zpH_gm<#I{y=t0YRB~B^g>;v90JVLU7N;-n0O#%QUok3Nc4Spf)(C6B zDUV}h_XFKr_@Qxzqkrh#F^yu|$tlY1kVdau;iN0sVKQp2@GeeB5VY>g0kQ>c`;>n1 zA2SMn+j_jrx`5bKaTGA;qpRh$)c%}$f11yHS9F30(w5D8v}wEV0!Y=K{cX3(_87PZ z+aK7MT;5Rg^!f%d9rY2y@4&Z|uOJe_&!8lBsFY9KV4EzrkEo7fUQe`m2a3ULx9|y- zl5xtP;XL6Z(hJC&!wFf~kE3?d(dHkM27m?+&l-u_x!W6ZFHG3VSp|K43i*R^?z8Kb z!0b?_EhJ21cUYQ{WVbP@unkrZ>SCiYC50D~+MNaGYqA6(H2o zwg5i?E~YGku!a0AKCQD1wtZK<>M_`k60zz%txK}y>UtSl0j^i8v4|44EIMn@svA<$9DP2#!DkFUW?llKn0v=tKD6_D#xa^ z)hrjkQGIfw6ZkJ4V+$p;AM1g*s{?)odL!puTk}QRfRb1RoHOo9P1>HXlW+cbMO-eO z9247x)>wb!Kfx6HpaN4wUtGBGOR)jnRmR(E?%Dj7Xx^Ilp>=d|1J?QOKz z#d7vBV~6eW9VBy|k_j~PWg{<{{%&>Gh-(@o`eTD99UxQ3`h$tM*pBR+Po z&l%HEpECT8ts=>|#F|Q-)tU22r2S00-lGh&bYRJWR!ts|wtD+HKhi(VTeEt)ggqIK zu4OHy?ZvP(&*t5(UWRS3dQfNY#gtTQ%Xe$G=hlE&qii|hx6YhijTlqXQB~@P*yyFr zr40}W|Bp6zrp!6XvEA2Eh5kfr(v5xl7@W6XR6c|fBV4P!64P-b<9>@$s~~H!iEC{V zwzN2ohV1mYwnj{}jg`ubY- z1uSWignYI1df74wsVr%sgl(~U)Mlx~6jis0-aA+B(ezscdF6?x|8>n(6(v*1Q-UTH?w zK@GlL++3gT!NyJ4Im{H9Yi$+x9s6tMR}r`rYRqE;L>v zu$%~%v_SL67a5))>?df*?>5th`kqFjw>1G-I7>J+}>QD>lAWU;P;~n%$teh}KSYIai@&_rKC^ z%}CLbWAi|iZc9HdZmw=_(0Z?Xj`A7hhWuk%E%q%Mt>JUYE3xFu@?y(&hDC|7ZkbrL z)gG&7Z5qa=dhpF#W6*WcNMJjV3%Od@UGR$jek8jY`wZqpBXe{^%uhd?!+lF%^YcEU z#Mu>!F)b*Tql3sK)~S)bUd|U>ZiOt(X=~n=5GhSu3_JI6362;8qvT%83(o|<2u31mQ$(t`FaH7(~WRWO%3woFpPI@ zjXlpcJ-bK8rmBz`@XP`g7*l(cEO!IW6pen4#!NEQcO0!2lfi=Prr*jFPp2A{Eq){do%IRP)65kVzl9{Pt=F@{fQJ#B=R za$Cz%jB)Ivye1FX@*CSdWA>?*h|@9Jxe*?#NAo;kch%4GSq~oY5$&RQK)(;C-4yp} zefk%g8}~Lp(9hk?u3~$>4KzN+7t=3$$YGhB$DH@FOW3HIyVbs`+uU+Z*AuX(@JF-{)}JvH|${dW^Q}>_Jp`ubc~YJl*vP z|F!HHD=LMHdcd~O2N+&2`yrMjw2q&)VdarUn2+TSq?fOFdAvoPiV|Ui~$b0U=J;X4fTh$h@`mRWCml3|Db=2Cu220lC zoYx%Qs}%9910Q#t!(G=48|(Q_YKsE!Jg`2mUeajz=fTa5$Ji7V>Dd#C zpJJqt6{k_BpbNda6|A}lORXgxOMeLs{gG(dXR9_x806D?s)r{o86+k&wv zI!hpJsx5Y(Y{b1lH?O^zZjy_eKT*e}NvGR4# z0e2L(H6PqMTIL4IAs2@8HT!pzmq$``i`!C*8+DdLZ+-d5uCEQ{l)$W%e;X!&Xq!;wJm8B`mmbIb3&e8yL6W92gEhr zk{$Vk#!&i%^=Ral#Spm`M##U;T)geCjW;s@5`&QyRegg zBP;pkl+jz$>m_W2(ip~mb2=XHj&f}jzDIIlA^uL1JWgtb;Bte`*YYqA?rcB zf?t+f-l6|>utVRcdpyl*WDM8sa@F~!zGB!`mnQG%!H$ZW_Fkd=2)DfU`nd~O2g9B? zc)5IwIHaOB$3LFOag_Iq&6UkfI@jPD-7$BWUi06h>0JA7oWEaezM-GKb|~lMUQda} z0hi#tbIwSAPuGGEGF#S(4I@!O@nEdx5~OU2$5`_oE4-&uEC#VZoY8^(J{X@Tn|yw z-JjG#hx_91e)>r5Q6y}k_Llkq-oUzhPrP|FNkm)EY#Q@;{%+#-Q{psM?%A)0oIWBe zsdfBd{hg2ni<_5a=V4xl=(k5SSC~IKk}yR;N~f}ORHB=ie0QS_u`RdPMJ-h$}t z6OD;)BEI9^o(0K(cXm3>Zp1TteUuu?it^>BSr0J6KBw_^Zy~q*Nq)W*9aMQrw*WQ- zu&(OUF!x)uQ<_FEwh2!#Q`zqBv-x7%Q`;)Y zfc@pI*cO(Z(?)F(km;CuJVFM-7WUIz0{zmnOeDjK`=&kLGCj<(nq+`FO!?MTS6;pRb3;H=PAr>{(>abwuu9>FRqqv68e_eDv zn38UZcwmsB+*5fu%9T_PuN`~JbRlEqr`9fUr4^%e55*49JF@y>#Vs|o#1^Do7=hF| zgyp)qbbZ9ZueDTeo!*-C!SZM3cx^(L=R{qsYj^gzw9e}FC~HgWP;ag*gDHgUMMjyq zJPxh;wx+!~Wb|u4=wf6vye8im_Y7>$&eu9r^4!nlHDn?$SMHPTdR0n8d&+B;!}Ur+ zNk?+#Om9qGN~><;Pr#Lw-bz`|;qKL3L=`dP?cHC`Yi;le=0=4z;>zcFjibkW#(w1O z#jV{sdQPaYRt%VCdB-y6^~mZq?`LUSwS@fwWa70MApcv6@bgK@<<$-yIc;l8DV8DB zj);Bj4oF@r#2JcptM%GSwt;RW~vL*{uZ|OC5B5~xltsKVcH)=8JM|L;o z0rj1WVoBYaR-E3@N+#?GM7!J1jJ11*)km2lzTK`8@`iYeb6`)W6DlENkW6F-)a~6- zN|?hKX_4->vDS7RPv`UCoa~-+hn0@#;#O(Jj?TxFjWw@7oNt#8wr!Ue@z zt^r7^^D~dL`dmB8N^O5sohkeuKaL`$Yu1@-I3=Xc6G99fPr^rlzQFlj^SmOPVyH*0 zr&#mZ`y1Kr^fl;Y<#Acn_!lKhynU_Z^J$qrW{U(puvq!q|6{HmX^zR7~yL z2MVpgtEM>WHr>Sc9sN&hn~(y}-Cb*$ zuobC()ae(Snraq%-56(8rzAMS4 zS@552AOBKo4y&O!2L(A|Uqw1#yQpD}45Y*QyeucFQez~hXQ$j+;_0JSN$h#QEffiB zQ+ot5lKwXJT^?oH>ESkONM*ZxrR#!}rN8Cc?A5q~to=x~8E#O9e-qxf5%QFAO*K~d zy)SF79h{dU_sN4?VC4or9->nFi9zDqtT_U`mYH9QpGX!YR^DK3yqF{d=WXKTN=Qj> zG`fbe##YKt1829nqiF7Zvn?_1TqHv{(LzuCez!EvcgAe5iA%&31U36gBPSkF8~g>O zme`elB5asHUDF;b%HmU)QoC8FX|$0HMCV?EZ_HY@}&1+mED>VvX(ve zwgZ={+BL1K)T+5+Eu%V`ZK3j-w^Gxx+Ro88C4}^FqeR`Vw_IOCs*-O9`}AW|X2B9# zx+H%w5~Ve?D@(gxxoGc49io=#Dw*ugT`_${r0A;|Fw%c12 zZP8QC>S8}gdWU!@{Mi-^UkiRIS1sE+jbA(uck4ftWHQFze%x~TQioe<$;kT+d8zti z`3)^thm3k;t&c!Br4`~@%bd=kS4#w__RfvDH2EBjd3RGRjbl1;@$4UiUM(^y8bMpt zm%U~ooze_t)Xwsiw$$pTob*cFBWQ(qC$xLC=;y7Qg){r9nRBi0*UL)P*2?bpc}Z*2 z%0ic=be>igTD%sWzS(^(>rSKMzj;)P@q2qxBG@QC=fQTnJ!LEZLSD?h%@6c*mvS)g zZEn+A|J_ZUmEWQ#Wd^ub_IyogQ4MwFD0@!o8le%D3v2OgrFT6#c`X*9a&^D-r|>@C z{&sA%=pJ+^BOKel$UVP9hma(Hi3$ich|! zs1eSRMBIpXbmO!}M5uV*AToOJHS@LU5=6}Mf48w*6)bQUno2Oh}Md?-JvJeZ_L`XWuNh`sq_0$$Ou&avMnZnljYD zVR;Q(>cTm0_DhvtV{KpL%rTrR%%@g>4v^TVhaSYwx5&<_wfBX`+yZ% zWb&Z3{Mv1&%zgPk4g;h%?9#$byz#jmwd2gKcIotwbxcd;Ra(4zUb*(Xcn7Yp+B3gP zG<$hiqO1J0o&;|pe{OV8dd%O5wIUKJ|HnzD+b;1LMsnMtIfC03U7OqTq{VIdZb@!y zj$NM}V2z+lb0oK2x^>*%z66UWnageO!HgQZy}YfVUFL5-BYgXu5BJ>ld+#=-Uhdk| z%KS{9S+IRx^33W(04dwcFDYN<5I?vEPPsUrs5e`GmZ@(@A@tPB*0BPLn?V z)zIzbZ4K=*-*dN?Z=dg|U2bm?S?NJki%ur@yR}Jrm6LEG)-|Ixhku}W4WtTM{`*zub=Me4GrYYZy5K>00(}L|_%* z4szI)y_UNrqaodq+z)B5o98%74%sz)l0LT`9uu;*`)&CW)qZ}LD6gN}$b)}QcLyL! z&z?VU7`|mM&T#28)p^{`wRhdzh7`Xizmzjvdbt}?>E~uhY0cc5hq+q1ms?6<&0GrC z`rUJXd#tn^yV)FpqyiWz8Iun{E1#PD}T4N-3_V+p6)!(=4r2)=Q!*Blr%9c6}cm+kIOctUcTDY*3Zc^vd&-A4{o+aE|ML4oWtST z8s>4nwwC=G5y_$+#ebzYj@wFe-MoE6m@zMg{+8y7OQWBMKAko5P4*o2NuZYQ<&{!c zHKdiDo=^4>kiF_m6E#+25~J-tP!2P?I7FSnG! zK5%KCwJ3d6Ds#D}l(xaWdo-W;giNd^U~b`dVyx#J(<^*})tsa0J??459XqA-cGNfU zD6`m_U7hK^y(IU|CBuF zOZ43nT9f(H^wih%_k=#bOizA6cU&J$6mL`85WxVyOP}7N@~9cNtX!RHLd{=O9jN^l zee;N3{fVBrNzYuO_S~TFZqeVX=k2^fpWmQ*zC6EUn|pPQo_RD;x?BFil7Vn zPw5rc{`K@Nq60Um%-2-MEh_UT`n}?`|L1e*ar)sb=u?3f0OzdPKEc zn(DzmHoQW6(4%Y9FLGXQ&?j+^j_Fy9(5;C&dW4doah>>cGK~(N!S|Pl+GXm)Q~Euj z*LW7MZ#q4?O`q`U!E>U^(PMYKa^GH~Iv&vvMg!}{m!{fIsBX08DbWLec|X)Ky#haO z(%+lZny=~E>r@6Kk6xzov9~c}kxPmwkj}TcGdHHFGg!XE?s3cxsa4+Rca@_=_=Hg8 zozV8IzVc}%UMGHEryt1I$s{QlwWsGYbCaYJGXt~iGR-H9(&cGXpU@|eN6dN5OqGhU z^XkFo=jpsj^i*E!Jihv=A1BlY%;H-#c90}U)-k`8G>=TMSZ|{JUZ_YkQUg1*^BWzncid8 zEYXkapK4`%V+{V&#QS4vG2{&WIHq2pAHat{O?|sU(giGlRAJ;E)05C6+K;hXNMy;E zt0izIjE}Ti1~TL2lwkBpJ}X%W)^nPF4oX;w3hfI234O;l1~djr0QW%wIWbtP_%Km= zOnx-p|84pXSj*?ib6k=47T_jIlq}gSO#N>}7xDYoQ-;DLdUbkUul0@H#&=Wepp~#g z7Ci<%=t|gm+z;&8!d;n&azPhj_X%1Mf9{uK9f#P{8Q~9S_Jbx`0vq`qX}FZ_<>K=l zI>`zM{4L#LgID;@!slq+23h&|BX(oyhCN~5SOn|>z|Tj{0H^+9+i4X@^F>tzM}IiuWbIy z=0B4b`78DD2O7<%oBy%-W%GZ?a(+s*uF=nT^!gVneMXq}fv8>I{5$y+|BZf>2e5)* zv0bI-L4!3c>`=zZ>-0JF7Df};3EYInzCks^db~bisE_y1anKsTQ0Tu$^qzIe_49h5 zK|qf!XP`8&_9;DuvKZ5o^ESFTiIyUdjrr}rbDwiZ<#J$kkJk(8OGxe(ELF^4<#Nq4 z&^hdrgml`ZdITMpgZnAh*GNvEPBH~ag$)V$emqGtEEQO4kWBbduq)xw{E422e+5ks z?-4$Uj^PcGbyz#_x!4MV+&-Zn%#^Puc?ZQ~`UEot-Wsf0%q-X&m;vwznW8JNz9jqa z+~?d;3FUgc-KKJ+Jh)Am^1~D@(9iU_HaS&V|4JzJ7qYW|oX+X}fe`IB+1kGlYTu{N zao^+pbFR4@*iX3xBC;GHPQac3u$t{sNF^c|uu0ixg_jShgI#?xNfB&tkxN%P+}FMg z`S0B4Tz-ZUb%&(-yJ?=>rPiUP&}(0l)`Gm>p-X1_C>8JDxGKo(Ral-En z`T^*(Q&mzhU4~(-6<6Jmi$rt|yPjWqV z&&yq{x)TB(nVX-)Jx1HWC*Ch1s|9CMZ}=t|=y0v`BRz`~FF4aIq=&Hvy_TNAPK4)Z z`(Kx*mT0W(K0W=xnQ#A0bLA?{8^pu}MY)VWL;QE{d~sjatn)$j-Ldv)@eFcw^qdAK8{BWkTW%GfwI%j_)X2~V}6Io#;fZltuFE}Fr_LY2!Yyp(}$GJ6u zCy(jL=M+tRLfQcDt=3C613wQ8LDZSE`XzGyo)8r4`LG{-ig*?g7OYfq@2on6Lz069 zTD+1AOH%j*KEPf@uQ(!)*K8{?&#scs04oqDc1nNIZqUO{dZCs>EX{ORE%Ik87I> zdSZ0^zMw30KR#uj>4@ezVopys@Rm-g#9wK|FnUba>iyN~-gA`3ZO<1JVc;Kd6OmWM z(U0iWHR2;8qx|=)>8YCmH~rqYbW5+duSo#OviEkNX_eLcMn?H+j&rSi|aQ62H|a`bslGJSq+)8Dq| zC4BDHOgw(@u!NF~Sm;&3PUpFcd5K#(B;JKjpHTJ$?D$ifqZr8&zFBkruihLFaNivfj9d7bcxJ9A3f=jLMg#gT z%#d=wgBE085-r1sqK)urG{4LJR3h!}XJ>>kXI@!YDe!3FgJZ289y!|Lmhzvm==x7+ zE$oB8Aljx)=lY3*l$; zsYGFI!dYG0U=LrOxA~NM+TvL1S>@et#0k_2tqV#CxnCe7Mg}f z9PdO@{pbn4aZdu4Ug+ABND_Q&L>(mZf|4wm@=4B)0?v$$6M*7FY5``ST2nvMd(0gE zB&GKm(_E{_w;lXukJDXu;WhHS=+d%;%_Bd`j^TpXX@xewS*4PtSTP z?WNoy{y(8nfac;IbBF{ZZUF4^@2H2CDessQ>qmCNgm!J+8S~a%dP-6DAs$hN)OYl= zmK*Bf_5Ouo=9@#p(rD}Z(J2AsksZXg{wlhg{x8~<|^dOKPh_5e1WAIVxL%Q<-Di5v2LxS zcTTm|GiT>-P7Ti(`75RjUnRQ`0%%M<<}`eOhBbt1z~OuFBhN*jqE$YPfPPuF5B$$u{HsG9zkI*82DfF`hhv<;$kg%Wg{;9|BLd5y^0CmpF<$7XG?x9d?#zju>C7 zt@ilJlh*jkcRccKuke zl|&Gc*@2be7vwu3F2wp0ulvTUhHmee)zB`F8}bo(6$2UYk0`n>a)mjPAJKf-wT?Ab zYmiyTXBr|Kvv+iDO1#p12u6pI?$ z{v#uVN0hmMjD_V^HrW>B%s}J?@jYX`QGztJ-ce6eJdFIj{Gk+QWv4;koG()yEeYD* zgG7vw2;?&()-Y%MmBzf$RyzAVw%gU%Jm-4tWi4GhR%}gaIgHK0hQf-*3B^6WqF>>S zVpEUB8&jzrq0n}UDed=sT7%sL3mG;tcKbm7v47?DWIyr#m0tWT)9sgnGVT4Ai*4g9 zJazVH@So2F=^baAR{z-A^!9r^m!IdBW)n2k9cO(qP)oa4CTi&)WMrP*oZ~Yx%lVW> z?DXid0_v%6Lr(nmA0%ZPl7bzOpd0Rhoo7ATa#OBrtQ3{&>y@cP{0^RmHOi19-mx?a zZH!9O==96E$_M@mRY z`ydx{{STZli2V(Ge*p6r5iPzWp;szORQqM3M0vj@V%xd{+`|b5&nZ6>xfmRohUUfR zb4EKyb>3*_DDU@ZuR$+hrsHl4&SLGAfRIZ6h=-I8BRmh`)u-;U1+{eVh$@A{NX{F{ zFsu6`A@)bo-J^2OU3$HvoonM^{6~yG=i~L^G>?u@m^a2kWxq#tyY?3Qv%T|EOZSeH zQrPcNTHa1dMJ8~HAFpWi&Bz+M^F}{jMRMDGkc)Yk%(v*_j6}Y1hEMJ5v9xSTy<=}v zJB;>-(RS}l#6Bf^t+o#jc-(4hm?s^zwH%~owAAPclKn{Gj-JvRClN~XF#dDLA7_Nm z^VQx`MAoIzKh8d#!`RLnTRFk75AC&d?|3SO!${5@$<*%S-my*7>mThj&HWz#?fT*A zUE1M^fj#=Tp87V%-9MXgzolS#Kc8eDA@W5sj(zj$=&eFna0H> GetLastActionLogsForDepartmentAsync(in var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("DisableAutoAvailable", disableAutoAvailable); dynamicParameters.Add("Timestamp", timeStamp); @@ -85,7 +85,7 @@ public async Task> GetAllActionLogsForUser(string userId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -128,7 +128,7 @@ public async Task> GetAllActionLogsForUserInDateRangeAsyn { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("StartDate", startDate); dynamicParameters.Add("EndDate", endDate); @@ -172,7 +172,7 @@ public async Task> GetAllActionLogsInDateRangeAsync(int d { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("StartDate", startDate); dynamicParameters.Add("EndDate", endDate); @@ -216,7 +216,7 @@ public async Task> GetAllActionLogsForDepartmentAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -260,7 +260,7 @@ public async Task GetLastActionLogsForUserAsync(string userId, bool d var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("DisableAutoAvailable", disableAutoAvailable); dynamicParameters.Add("Timestamp", timeStamp); @@ -308,7 +308,7 @@ public async Task> GetActionLogsForCallAsync(int callId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); @@ -351,14 +351,14 @@ public async Task> GetActionLogsForCallAndTypesAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", destinationId); var usersToQuery = String.Join(",", types.Select(p => $"{p.ToString()}").ToArray()); //dynamicParameters.Add("Types", usersToQuery); var query = _queryFactory.GetQuery(); - query = query.Replace("%TYPES%", usersToQuery); + query = query.Replace("%TYPES%", usersToQuery, StringComparison.InvariantCultureIgnoreCase); return await x.QueryAsync(sql: query, param: dynamicParameters, @@ -398,7 +398,7 @@ public async Task GetPreviousActionLogAsync(string userId, int action { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("ActionLogId", actionLogId); @@ -444,7 +444,7 @@ public async Task GetLastActionLogForUserAsync(string userId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CalendarItemAttendeeRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CalendarItemAttendeeRepository.cs index 6240e51d..9b699122 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CalendarItemAttendeeRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CalendarItemAttendeeRepository.cs @@ -34,7 +34,7 @@ public async Task GetCalendarItemAttendeeByUserAsync(int c { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CalendarItemId", calendarEventItemId); dynamicParameters.Add("UserId", userId); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CalendarItemsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CalendarItemsRepository.cs index 5da60f72..5a3f0b65 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CalendarItemsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CalendarItemsRepository.cs @@ -37,7 +37,7 @@ public async Task> GetCalendarItemsByRecurrenceIdAsync { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CalendarItemId", id); var query = _queryFactory.GetQuery(); @@ -80,7 +80,7 @@ public async Task DeleteCalendarItemAndRecurrencesAsync(int id, Cancellati { try { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CalendarItemId", id); var query = _queryFactory.GetDeleteQuery(); @@ -128,7 +128,7 @@ public async Task> GetAllCalendarItemsToNotifyAsync(Da { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("StartDate", startDate); var query = _queryFactory.GetQuery(); @@ -169,7 +169,7 @@ public async Task GetCalendarItemByIdAsync(int calendarItemId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CalendarItemId", calendarItemId); var query = _queryFactory.GetQuery(); @@ -217,7 +217,7 @@ public async Task> GetAllCalendarItemsByDepartmentIdAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallAttachmentRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallAttachmentRepository.cs index 20a933b3..38cea416 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallAttachmentRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallAttachmentRepository.cs @@ -35,7 +35,7 @@ public async Task GetCallAttachmentByCallIdAndTypeAsync(int call { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); dynamicParameters.Add("Type", (int)type); @@ -77,7 +77,7 @@ public async Task> GetCallDispatchesByCallIdAsync(in { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchGroupRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchGroupRepository.cs index 84a29848..dba7c9ec 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchGroupRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchGroupRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllCallDispatchGroupByGroup { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", groupId); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task> GetAllCallDispatchGroupByCallI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchRoleRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchRoleRepository.cs index f2ac42d9..050e7a1c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchRoleRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchRoleRepository.cs @@ -35,7 +35,7 @@ public async Task> GetCallRoleDispatchesByCallIdAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchUnitRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchUnitRepository.cs index e85b913b..933dde64 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchUnitRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchUnitRepository.cs @@ -35,7 +35,7 @@ public async Task> GetCallUnitDispatchesByCallIdAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchesRepository.cs index 33726235..f13e30ec 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallDispatchesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallDispatchesRepository.cs @@ -50,7 +50,7 @@ public async Task MarkCallDispatchesAsSentByCallIdUsersAsync(int callId, L var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); dynamicParameters.Add("UserIds", userIds.ToString()); @@ -94,7 +94,7 @@ public async Task> GetCallDispatchesByCallIdAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallLogsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallLogsRepository.cs index 30328952..392fdbcb 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallLogsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallLogsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetLogsForUserAsync(string userId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task> GetLogsForCallAsync(int callId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallNotesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallNotesRepository.cs index 0f940fbf..a75b1c0d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallNotesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallNotesRepository.cs @@ -35,7 +35,7 @@ public async Task> GetCallNotesByCallIdAsync(int callId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallProtocolsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallProtocolsRepository.cs index 9448a73a..ec09b00e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallProtocolsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallProtocolsRepository.cs @@ -34,7 +34,7 @@ public async Task> GetCallProtocolsByCallIdAsync(int c { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallReferencesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallReferencesRepository.cs index 138ef2c8..05126fd9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallReferencesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallReferencesRepository.cs @@ -38,7 +38,7 @@ public async Task> GetCallReferencesByTargetCallIdAsy { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); @@ -82,7 +82,7 @@ public async Task> GetCallReferencesBySourceCallIdAsy { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/CallsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CallsRepository.cs index ca5ab1f2..a476f5ac 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CallsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CallsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllCallsByDepartmentDateRangeAsync(int d { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("StartDate", startDate); dynamicParameters.Add("EndDate", endDate); @@ -78,7 +78,7 @@ public async Task> GetAllClosedCallsByDepartmentAsync(int depa { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -119,9 +119,9 @@ public async Task> GetAllClosedCallsByDepartmentYearAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); - dynamicParameters.Add("Year", year); + dynamicParameters.Add("Year", int.Parse(year)); var query = _queryFactory.GetQuery(); @@ -161,7 +161,7 @@ public async Task> GetAllOpenCallsByDepartmentAsync(int depart { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -202,7 +202,7 @@ public async Task> GetAllCallsByDepartmentIdLoggedOnAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("Date", loggedOn); @@ -244,7 +244,7 @@ public async Task> SelectCallYearsByDeptAsync(int department { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -285,7 +285,7 @@ public async Task> GetAllNonDispatchedScheduledCallsWithinDate { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("StartDate", startDate); dynamicParameters.Add("EndDate", endDate); @@ -327,7 +327,7 @@ public async Task> GetAllNonDispatchedScheduledCallsByDepartme { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Configs/SqlConfiguration.cs b/Repositories/Resgrid.Repositories.DataRepository/Configs/SqlConfiguration.cs index 0f259889..1d49c990 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Configs/SqlConfiguration.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Configs/SqlConfiguration.cs @@ -11,6 +11,7 @@ protected SqlConfiguration() { } public string TableColumnStartNotation { get; set; } public string TableColumnEndNotation { get; set; } public string InsertGetReturnIdCommand { get; set; } + public string QueryPrefix { get; set; } #region Common public string InsertQuery { get; set; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/CustomStateRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/CustomStateRepository.cs index 0bb78683..503a0dd6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/CustomStateRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/CustomStateRepository.cs @@ -36,7 +36,7 @@ public async Task> GetCustomStatesByDepartmentIdAsync(i { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -84,7 +84,7 @@ public async Task GetCustomStatesByIdAsync(int customStateId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CustomStateId", customStateId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentCallPruningRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentCallPruningRepository.cs index 660a7f3b..049e24ea 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentCallPruningRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentCallPruningRepository.cs @@ -35,7 +35,7 @@ public async Task GetDepartmentCallPruningSettingsAsync(i { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupMembersRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupMembersRepository.cs index d958b871..ace69454 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupMembersRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupMembersRepository.cs @@ -36,7 +36,7 @@ public async Task> GetAllGroupMembersByGroupI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", groupId); var query = _queryFactory.GetQuery(); @@ -77,7 +77,7 @@ public async Task> GetAllGroupMembersByUserAn { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("DepartmentId", departmentId); @@ -123,7 +123,7 @@ public async Task> GetAllGroupMembersByUserAn { try { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", groupId); dynamicParameters.Add("DepartmentId", departmentId); @@ -173,7 +173,7 @@ public async Task> GetAllGroupAdminsByDepartm { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs index 54e0b513..cc956eca 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentGroupsRepository.cs @@ -73,7 +73,7 @@ public async Task> GetAllGroupsByDepartmentIdAsync( { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -121,7 +121,7 @@ public async Task> GetAllGroupsByParentGroupIdAsync { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", parentGroupId); var query = _queryFactory.GetQuery(); @@ -169,7 +169,7 @@ public async Task GetGroupByGroupIdAsync(int departmentGroupId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", departmentGroupId); var query = _queryFactory.GetQuery(); @@ -217,7 +217,7 @@ public async Task GetGroupByDispatchCodeAsync(string dispatchCo { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DispatchEmail", dispatchCode); var query = _queryFactory.GetQuery(); @@ -265,7 +265,7 @@ public async Task GetGroupByMessageCodeAsync(string messageCode { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("MessageEmail", messageCode); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentLinksRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentLinksRepository.cs index b491a025..cfee282e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentLinksRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentLinksRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllLinksForDepartmentAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task> GetAllLinksForDepartmentAndIdAsyn { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("Id", departmentLinkId); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentMembersRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentMembersRepository.cs index 99b78900..92b331c5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentMembersRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentMembersRepository.cs @@ -37,7 +37,7 @@ public async Task> GetAllDepartmentMembersWithinLi { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -80,7 +80,7 @@ public async Task> GetAllDepartmentMembersUnlimite { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -123,7 +123,7 @@ public async Task> GetAllDepartmentMembersUnlimite { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -166,7 +166,7 @@ public async Task GetDepartmentMemberByDepartmentIdAndUserIdAs { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("UserId", userId); @@ -211,7 +211,7 @@ public async Task> GetAllDepartmentMemberByUserIdA { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentSettingsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentSettingsRepository.cs index e30bc32e..cc5d9b57 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentSettingsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentSettingsRepository.cs @@ -35,7 +35,7 @@ public async Task GetDepartmentSettingByUserIdTypeAsync(strin { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("SettingType", (int)type); @@ -79,7 +79,7 @@ public async Task GetDepartmentSettingByIdTypeAsync(int depar { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("SettingType", (int)type); @@ -121,7 +121,7 @@ public async Task GetDepartmentSettingBySettingTypeAsync(stri { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Setting", setting); dynamicParameters.Add("SettingType", (int)type); @@ -163,7 +163,7 @@ public async Task> GetAllDepartmentManagerInfoAsync( { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); var query = _queryFactory.GetQuery(); @@ -203,7 +203,7 @@ public async Task GetDepartmentManagerInfoByEmailAsync(st { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("EmailAddress", emailAddress); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceChannelRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceChannelRepository.cs index 7b450688..1dc2e15b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceChannelRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceChannelRepository.cs @@ -36,7 +36,7 @@ public async Task> GetDepartmentVoiceChannel { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentVoiceId", voiceId); var query = _queryFactory.GetQuery(); @@ -79,7 +79,7 @@ public async Task> GetDepartmentVoiceChannel { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceRepository.cs index e581cd0e..4aaba72c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceRepository.cs @@ -36,7 +36,7 @@ public async Task GetDepartmentVoiceByDepartmentIdAsync(int dep { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceUserRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceUserRepository.cs index c2a8db28..9fb1ed3a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceUserRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentVoiceUserRepository.cs @@ -36,7 +36,7 @@ public async Task GetDepartmentVoiceUserByUserIdAsync(strin { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DepartmentsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DepartmentsRepository.cs index 8c0b89e4..661a834b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DepartmentsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DepartmentsRepository.cs @@ -37,7 +37,7 @@ public async Task GetDepartmentWithMembersByIdAsync(int departmentId { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -103,7 +103,7 @@ public async Task GetDepartmentWithMembersByNameAsync(string name) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Name", name); var query = _queryFactory.GetQuery(); @@ -168,7 +168,7 @@ public async Task GetValidateUserForDepartmentD { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Username", userName); var query = _queryFactory.GetQuery(); @@ -209,7 +209,7 @@ public async Task GetDepartmentForUserByUserIdAsync(string userId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -275,7 +275,7 @@ public async Task GetDepartmentForUserByUsernameAsync(string userNam { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Username", userName); var query = _queryFactory.GetQuery(); @@ -340,7 +340,7 @@ public async Task GetDepartmentReportAsync(int departmentId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -381,7 +381,7 @@ public async Task GetByLinkCodeAsync(string code) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Code", code); var query = _queryFactory.GetQuery(); @@ -446,7 +446,7 @@ public async Task GetDepartmentStatsByDepartmentUserIdAsync(int { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("UserId", userId); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolAttachmentRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolAttachmentRepository.cs index 79f0ae0f..416d910b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolAttachmentRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolAttachmentRepository.cs @@ -35,7 +35,7 @@ public async Task> GetDispatchProtocolAt { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ProtocolId", protocolId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolQuestionsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolQuestionsRepository.cs index 2bc28e8b..b8b0feba 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolQuestionsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolQuestionsRepository.cs @@ -36,7 +36,7 @@ public async Task> GetDispatchProtocolQues { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ProtocolId", protocolId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolRepository.cs index c4cf8af0..a9b6b68d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolRepository.cs @@ -37,7 +37,7 @@ public async Task GetDispatchProtocolByIdAsync(int protocolId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ProtocolId", protocolId); var query = _queryFactory.GetQuery(); @@ -85,7 +85,7 @@ public async Task> GetDispatchProtocolsByDepartmen { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolTriggersRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolTriggersRepository.cs index 3332c4a3..5b2ffc3a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolTriggersRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DispatchProtocolTriggersRepository.cs @@ -35,7 +35,7 @@ public async Task> GetDispatchProtocolTrigg { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ProtocolId", protocolId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DistributionListMemberRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DistributionListMemberRepository.cs index 59a2f3a2..da38204f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DistributionListMemberRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DistributionListMemberRepository.cs @@ -36,7 +36,7 @@ public async Task> GetDistributionListMember var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ListId", listId); var query = _queryFactory.GetQuery(); @@ -79,7 +79,7 @@ public async Task> GetDistributionListMember var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/DistributionListRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/DistributionListRepository.cs index c1bdaeaf..31d6e835 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/DistributionListRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/DistributionListRepository.cs @@ -37,7 +37,7 @@ public async Task GetDistributionListByEmailAddressAsync(strin var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("EmailAddress", email); var query = _queryFactory.GetQuery(); @@ -80,7 +80,7 @@ public async Task> GetAllActiveDistributionListsAs var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); var query = _queryFactory.GetQuery(); @@ -122,7 +122,7 @@ public async Task> GetDispatchProtocolsByDepartmen { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -170,7 +170,7 @@ public async Task GetDistributionListByIdAsync(int distributio { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ListId", distributionListId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Extensions/CitextParameter.cs b/Repositories/Resgrid.Repositories.DataRepository/Extensions/CitextParameter.cs new file mode 100644 index 00000000..22b83190 --- /dev/null +++ b/Repositories/Resgrid.Repositories.DataRepository/Extensions/CitextParameter.cs @@ -0,0 +1,27 @@ +using Dapper; +using Npgsql; +using NpgsqlTypes; +using System.Data; + +namespace Resgrid.Repositories.DataRepository.Extensions +{ + public class CitextParameter : SqlMapper.ICustomQueryParameter + { + readonly string _value; + + public CitextParameter(string value) + { + _value = value; + } + + public void AddParameter(IDbCommand command, string name) + { + command.Parameters.Add(new NpgsqlParameter + { + ParameterName = name, + NpgsqlDbType = NpgsqlDbType.Citext, + Value = _value + }); + } + } +} diff --git a/Repositories/Resgrid.Repositories.DataRepository/Extensions/ColumnsBuilderExtensions.cs b/Repositories/Resgrid.Repositories.DataRepository/Extensions/ColumnsBuilderExtensions.cs index b3f9d3cf..9f332a32 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Extensions/ColumnsBuilderExtensions.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Extensions/ColumnsBuilderExtensions.cs @@ -1,5 +1,6 @@ // From https://github.com/grandchamp/Identity.Dapper +using Resgrid.Config; using Resgrid.Model; using Resgrid.Repositories.DataRepository.Configs; using System; @@ -59,6 +60,11 @@ public static IEnumerable GetColumns(this TEntity entity, SqlCo roleProperties = roleProperties.Select(y => string.Concat(sqlConfiguration.TableColumnStartNotation, y, sqlConfiguration.TableColumnEndNotation)); + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + roleProperties = roleProperties.Select(x => x.ToLower()); + } + return roleProperties; } } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Extensions/DynamicParametersExtension.cs b/Repositories/Resgrid.Repositories.DataRepository/Extensions/DynamicParametersExtension.cs new file mode 100644 index 00000000..b5caaf29 --- /dev/null +++ b/Repositories/Resgrid.Repositories.DataRepository/Extensions/DynamicParametersExtension.cs @@ -0,0 +1,37 @@ +using Dapper; +using Resgrid.Config; +using Resgrid.Repositories.DataRepository.Extensions; +using System; +using System.Data; + +namespace Resgrid.Repositories.DataRepository +{ + internal class DynamicParametersExtension: DynamicParameters + { + public DynamicParametersExtension() + { + } + + public DynamicParametersExtension(object template) + { + AddDynamicParams(template); + } + + public void Add(string name, object? value = null, DbType? dbType = null, ParameterDirection? direction = null, int? size = null, byte? precision = null, byte? scale = null) + { + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + name = name.ToLower(); + + if (value is String newValue && dbType == null) + base.Add(name, new CitextParameter(newValue), dbType, direction, size); + else + base.Add(name, value, dbType, direction, size); + } + else + { + base.Add(name, value, dbType, direction, size); + } + } + } +} diff --git a/Repositories/Resgrid.Repositories.DataRepository/Extensions/SqlQueryParametersExtensions.cs b/Repositories/Resgrid.Repositories.DataRepository/Extensions/SqlQueryParametersExtensions.cs index de696942..2c442eea 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Extensions/SqlQueryParametersExtensions.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Extensions/SqlQueryParametersExtensions.cs @@ -1,5 +1,6 @@ // From https://github.com/grandchamp/Identity.Dapper +using Resgrid.Config; using System; using System.Collections.Generic; using System.Linq; @@ -11,8 +12,12 @@ public static class SqlQueryParametersExtensions { public static List InsertQueryValuesFragment(this List valuesArray, string parameterNotation, IEnumerable propertyNames) { - foreach (var property in propertyNames) - valuesArray.Add($"{parameterNotation}{property.RemoveSpecialCharacters()}"); + //if (DataConfig.DatabaseType == DatabaseType.Postgres) + // foreach (var property in propertyNames) + // valuesArray.Add($"{parameterNotation}{property.RemoveSpecialCharacters().ToLower()}"); + //else + foreach (var property in propertyNames) + valuesArray.Add($"{parameterNotation}{property.RemoveSpecialCharacters()}"); return valuesArray; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Extensions/StringReplaceExtensions.cs b/Repositories/Resgrid.Repositories.DataRepository/Extensions/StringReplaceExtensions.cs index 1af06658..dbd126ee 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Extensions/StringReplaceExtensions.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Extensions/StringReplaceExtensions.cs @@ -1,5 +1,7 @@ // From https://github.com/grandchamp/Identity.Dapper +using Resgrid.Config; +using Resgrid.Repositories.DataRepository.Configs; using System.Text; using System.Text.RegularExpressions; @@ -7,49 +9,81 @@ namespace Resgrid.Repositories.DataRepository.Extensions { public static class StringReplaceExtensions { - public static string ReplaceInsertQueryParameters(this string query, string schemaName, string tableName, string returnIdCmd, string columns, string values) + public static string ReplaceInsertQueryParameters(this string query, SqlConfiguration sqlConfiguration, string schemaName, string tableName, string returnIdCmd, string columns, string values) { - return query.Replace("%SCHEMA%", schemaName) - .Replace("%TABLENAME%", tableName) - .Replace("%RETURNID%", returnIdCmd) - .Replace("%COLUMNS%", $"({columns})") - .Replace("%VALUES%", values); + query = $"{sqlConfiguration.QueryPrefix} {query}"; + + return query.Replace("%SCHEMA%", schemaName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%TABLENAME%", tableName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%RETURNID%", returnIdCmd, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%COLUMNS%", $"({columns})", System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%VALUES%", values, System.StringComparison.InvariantCultureIgnoreCase); } - public static string ReplaceDeleteQueryParameters(this string query, string schemaName, string tableName, string idColumnName, string idParameter) + public static string ReplaceDeleteQueryParameters(this string query, SqlConfiguration sqlConfiguration, string schemaName, string tableName, string idColumnName, string idParameter) { - return query.Replace("%SCHEMA%", schemaName) - .Replace("%TABLENAME%", tableName) - .Replace("%IDCOLUMN%", idColumnName) - .Replace("%ID%", idParameter); + query = $"{sqlConfiguration.QueryPrefix} {query}"; + + return query.Replace("%SCHEMA%", schemaName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%TABLENAME%", tableName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%IDCOLUMN%", idColumnName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%ID%", idParameter, System.StringComparison.InvariantCultureIgnoreCase); } - public static string ReplaceUpdateQueryParameters(this string query, string schemaName, string tableName, string setValues, string idColumnName, string idParameter) + public static string ReplaceUpdateQueryParameters(this string query, SqlConfiguration sqlConfiguration, string schemaName, string tableName, string setValues, string idColumnName, string idParameter) { - return query.Replace("%SCHEMA%", schemaName) - .Replace("%TABLENAME%", tableName) - .Replace("%IDCOLUMN%", idColumnName) - .Replace("%SETVALUES%", setValues) - .Replace("%ID%", idParameter); + query = $"{sqlConfiguration.QueryPrefix} {query}"; + + return query.Replace("%SCHEMA%", schemaName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%TABLENAME%", tableName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%IDCOLUMN%", idColumnName, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%SETVALUES%", setValues, System.StringComparison.InvariantCultureIgnoreCase) + .Replace("%ID%", idParameter, System.StringComparison.InvariantCultureIgnoreCase); } - public static string ReplaceQueryParameters(this string query, string schemaName, string tableName, string parameterNotation, string[] parameterPlaceholders, string[] sqlParameterValues) + public static string ReplaceQueryParameters(this string query, SqlConfiguration sqlConfiguration, string schemaName, string tableName, string parameterNotation, string[] parameterPlaceholders, string[] sqlParameterValues) { + query = $"{sqlConfiguration.QueryPrefix} {query}"; + + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + query = query.ToLower(); + var queryBuilder = new StringBuilder(query); for (int i = 0; i < parameterPlaceholders.Length; i++) - queryBuilder.Replace($"{parameterPlaceholders[i]}", $"{parameterNotation}{sqlParameterValues[i]}"); + { + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + queryBuilder.Replace($"{parameterPlaceholders[i].ToLower()}", $"{parameterNotation}{sqlParameterValues[i].ToLower()}"); + else + queryBuilder.Replace($"{parameterPlaceholders[i]}", $"{parameterNotation}{sqlParameterValues[i]}"); + } - queryBuilder.Replace("%SCHEMA%", schemaName) - .Replace("%TABLENAME%", tableName); + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + queryBuilder.Replace("%schema%", schemaName) + .Replace("%tablename%", tableName); + else + queryBuilder.Replace("%SCHEMA%", schemaName) + .Replace("%TABLENAME%", tableName); + //.Replace("%TABLENAME%", $"{sqlConfiguration.TableColumnStartNotation}{tableName}{sqlConfiguration.TableColumnEndNotation}"); return queryBuilder.ToString(); } - public static string ReplaceQueryParameters(this string query, string schemaName, string tableName, string parameterNotation, string[] parameterPlaceholders, string[] sqlParameterValues, string[] othersPlaceholders, string[] othersPlaceholdersValues) + public static string ReplaceQueryParameters(this string query, SqlConfiguration sqlConfiguration, string schemaName, string tableName, string parameterNotation, string[] parameterPlaceholders, string[] sqlParameterValues, string[] othersPlaceholders, string[] othersPlaceholdersValues) { - var queryBuilder = new StringBuilder(query.ReplaceQueryParameters(schemaName, tableName, parameterNotation, parameterPlaceholders, sqlParameterValues)); + query = $"{sqlConfiguration.QueryPrefix} {query}"; + + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + query = query.ToLower(); + + var queryBuilder = new StringBuilder(query.ReplaceQueryParameters(sqlConfiguration, schemaName, tableName, parameterNotation, parameterPlaceholders, sqlParameterValues)); for (int i = 0; i < othersPlaceholders.Length; i++) - queryBuilder.Replace(othersPlaceholders[i], othersPlaceholdersValues[i]); + { + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + queryBuilder.Replace(othersPlaceholders[i].ToLower(), othersPlaceholdersValues[i].ToLower()); + else + queryBuilder.Replace(othersPlaceholders[i], othersPlaceholdersValues[i]); + } + //queryBuilder.Replace(othersPlaceholders[i], $"{sqlConfiguration.TableColumnStartNotation}{othersPlaceholdersValues[i]}{sqlConfiguration.TableColumnEndNotation}" ); return queryBuilder.ToString(); } diff --git a/Repositories/Resgrid.Repositories.DataRepository/FormAutomationsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/FormAutomationsRepository.cs index 4e8837d0..70d3006f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/FormAutomationsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/FormAutomationsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetFormAutomationsByFormIdAsync(s { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("FormId", formId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/FormsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/FormsRepository.cs index fde5db68..7c1bee01 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/FormsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/FormsRepository.cs @@ -36,7 +36,7 @@ public async Task
GetFormByIdAsync(string formId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("FormId", formId); var query = _queryFactory.GetQuery(); @@ -84,7 +84,7 @@ public async Task> GetFormsByDepartmentIdAsync(int departmentI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -132,7 +132,7 @@ public async Task> GetNonDeletedFormsByDepartmentIdAsync(int d { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -180,7 +180,7 @@ public async Task EnableFormByIdAsync(string id) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("FormId", id); var query = _queryFactory.GetQuery(); @@ -223,7 +223,7 @@ public async Task DisableFormByIdAsync(string id) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("FormId", id); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs index 447d5368..ba7feb50 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/IdentityRepository.cs @@ -11,16 +11,27 @@ using Resgrid.Model.Repositories; using Resgrid.Model; using Resgrid.Config; +using Npgsql; namespace Resgrid.Repositories.DataRepository { - public class IdentityRepository: IIdentityRepository + public class IdentityRepository : IIdentityRepository { public List GetAll() { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - return db.Query($"SELECT * FROM AspNetUsers").ToList(); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query($"SELECT * FROM aspnetusers").ToList(); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query($"SELECT * FROM AspNetUsers").ToList(); + } } return null; @@ -28,31 +39,43 @@ public List GetAll() public IdentityUser GetUserById(string userId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query($"SELECT * FROM aspnetusers WHERE id = @userId", new { userId = userId }).FirstOrDefault(); + } + } + else { - return db.Query($"SELECT * FROM AspNetUsers WHERE Id = @userId", new { userId = userId }).FirstOrDefault(); + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query($"SELECT * FROM AspNetUsers WHERE Id = @userId", new { userId = userId }).FirstOrDefault(); + } } return null; } - //public IdentityUser GetUserByUserName(string userName) - //{ - // using (IDbConnection db = new SqlConnection(connectionString)) - // { - // return db.Query($"SELECT * FROM AspNetUsers WHERE UserName = @userName", new { userName = userName }).FirstOrDefault(); - // } - - // return null; - //} - public async Task GetUserByUserNameAsync(string userName) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - var result = await db.QueryAsync($"SELECT * FROM AspNetUsers WHERE UserName = @userName", new { userName = userName }); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var result = await db.QueryAsync($"SELECT * FROM aspnetusers WHERE username = @userName", new { userName = userName }); - return result.FirstOrDefault(); + return result.FirstOrDefault(); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + var result = await db.QueryAsync($"SELECT * FROM AspNetUsers WHERE UserName = @userName", new { userName = userName }); + + return result.FirstOrDefault(); + } } return null; @@ -60,9 +83,19 @@ public async Task GetUserByUserNameAsync(string userName) public IdentityUser GetUserByEmail(string email) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - return db.Query($"SELECT * FROM AspNetUsers WHERE Email = @email", new { email = email }).FirstOrDefault(); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query($"SELECT * FROM aspnetusers WHERE email = @email", new { email = email }).FirstOrDefault(); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query($"SELECT * FROM AspNetUsers WHERE Email = @email", new { email = email }).FirstOrDefault(); + } } return null; @@ -70,42 +103,93 @@ public IdentityUser GetUserByEmail(string email) public void UpdateUsername(string oldUsername, string newUsername) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - db.Execute($"UPDATE [AspNetUsers] SET [UserName] = @newUsername, [NormalizedUserName] = @newUsernameUpper WHERE UserName = @oldUsername", new { newUsername = newUsername, newUsernameUpper = newUsername.ToUpper(), oldUsername = oldUsername }); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + db.Execute($"UPDATE public.aspnetusers SET username = @newUsername, normalizedusername = @newUsernameUpper WHERE username = @oldUsername", new { newUsername = newUsername, newUsernameUpper = newUsername.ToUpper(), oldUsername = oldUsername }); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + db.Execute($"UPDATE [AspNetUsers] SET [UserName] = @newUsername, [NormalizedUserName] = @newUsernameUpper WHERE UserName = @oldUsername", new { newUsername = newUsername, newUsernameUpper = newUsername.ToUpper(), oldUsername = oldUsername }); + } } } public void UpdateEmail(string userId, string newEmail) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + db.Execute($"UPDATE public.aspnetusers SET email = @newEmail WHERE id = @userId", new { userId = userId, newEmail = newEmail }); + } + } + else { - db.Execute($"UPDATE [AspNetUsers] SET [Email] = @newEmail, [NormalizedEmail] = @newEmailUpper WHERE Id = @userId", new { userId = userId, newEmail = newEmail, newEmailUpper = newEmail.ToUpper() }); + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + db.Execute($"UPDATE [AspNetUsers] SET [Email] = @newEmail, [NormalizedEmail] = @newEmailUpper WHERE Id = @userId", new { userId = userId, newEmail = newEmail, newEmailUpper = newEmail.ToUpper() }); + } } } public void AddUserToRole(string userId, string roleId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - db.Execute($"INSERT INTO AspNetUserRoles ([UserId] ,[RoleId]) VALUES (@userId, @roleId)", new { userId = userId, roleId = roleId }); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + db.Execute($"INSERT INTO public.aspnetuserroles ([userid] ,[roleid]) VALUES (@userId, @roleId)", new { userId = userId, roleId = roleId }); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + db.Execute($"INSERT INTO AspNetUserRoles ([UserId] ,[RoleId]) VALUES (@userId, @roleId)", new { userId = userId, roleId = roleId }); + } } } public void InitUserExtInfo(string userId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - db.Execute($"INSERT INTO AspNetUsersExt ([UserId] ,[CreateDate] ,[LastActivityDate]) VALUES (@userId,@dateTimeNow,@dateTimeNow)", new { userId = userId, dateTimeNow = DateTime.UtcNow }); - db.Execute($"UPDATE [dbo].[AspNetUsers] SET [EmailConfirmed] = 1 WHERE Id = @userId", new { userId = userId }); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + db.Execute($"INSERT INTO public.aspnetusersext ([userid] ,[createdate] ,[lastactivitydate]) VALUES (@userId,@dateTimeNow,@dateTimeNow)", new { userId = userId, dateTimeNow = DateTime.UtcNow }); + db.Execute($"UPDATE public.aspnetusers SET emailconfirmed = 1 WHERE id = @userId", new { userId = userId }); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + db.Execute($"INSERT INTO AspNetUsersExt ([UserId] ,[CreateDate] ,[LastActivityDate]) VALUES (@userId,@dateTimeNow,@dateTimeNow)", new { userId = userId, dateTimeNow = DateTime.UtcNow }); + db.Execute($"UPDATE [dbo].[AspNetUsers] SET [EmailConfirmed] = 1 WHERE Id = @userId", new { userId = userId }); + } } } public IdentityUserRole GetRoleForUserRole(string userId, string roleId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query($"SELECT * FROM aspnetuserroles WHERE userid = @userId AND roleid = @roleId", new { userId = userId, roleId = roleId }).FirstOrDefault(); + } + } + else { - return db.Query($"SELECT * FROM AspNetUserRoles WHERE UserId = @userId AND RoleId = @roleId", new { userId = userId, roleId = roleId }).FirstOrDefault(); + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query($"SELECT * FROM AspNetUserRoles WHERE UserId = @userId AND RoleId = @roleId", new { userId = userId, roleId = roleId }).FirstOrDefault(); + } } return null; @@ -113,23 +197,45 @@ public IdentityUserRole GetRoleForUserRole(string userId, string roleId) public IdentityUser Update(IdentityUser user) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - db.Update(user); + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + db.Update(user); + } + return user; + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + db.Update(user); + } + return user; } - - return user; return null; } public List GetAllMembershipsForDepartment(int departmentId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query(@"SELECT m.* FROM aspnetusers m + INNER JOIN departmentmembers dm ON dm.userid = m.id + WHERE dm.departmentid = @departmentId AND dm.isdeleted = 0", new { departmentId = departmentId }).ToList(); + } + } + else { - return db.Query(@"SELECT m.* FROM AspNetUsers m + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query(@"SELECT m.* FROM AspNetUsers m INNER JOIN DepartmentMembers dm ON dm.UserId = m.Id WHERE dm.DepartmentId = @departmentId AND dm.IsDeleted = 0", new { departmentId = departmentId }).ToList(); + } } return null; @@ -137,11 +243,23 @@ public List GetAllMembershipsForDepartment(int departmentId) public List GetAllUsersForDepartment(int departmentId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - return db.Query(@"SELECT u.* FROM AspNetUsers u + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query(@"SELECT u.* FROM aspnetusers u + INNER JOIN departmentmembers dm ON dm.userid = u.id + WHERE dm.departmentid = @departmentId AND dm.isdeleted = 0", new { departmentId = departmentId }).ToList(); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id WHERE dm.DepartmentId = @departmentId AND dm.IsDeleted = 0", new { departmentId = departmentId }).ToList(); + } } return null; @@ -149,13 +267,28 @@ public List GetAllUsersForDepartment(int departmentId) public List GetAllUsersForGroup(int groupId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query(@"SELECT u.* + FROM aspnetusers u + INNER JOIN departmentgroupmembers dgm ON u.id = dgm.userid + INNER JOIN departmentmembers dm ON u.id = dm.userid + WHERE dgm.departmentgroupid = @groupId AND dm.isdeleted = 0", + new { groupId = groupId }).ToList(); + } + } + else { - return db.Query(@"SELECT u.* + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentGroupMembers dgm ON u.Id = dgm.UserId INNER JOIN DepartmentMembers dm ON u.Id = dm.UserId WHERE dgm.DepartmentGroupId = @groupId AND dm.IsDeleted = 0", new { groupId = groupId }).ToList(); + } } return null; @@ -163,30 +296,25 @@ FROM AspNetUsers u public List GetAllUsersForDepartmentWithinLimits(int departmentId, bool retrieveHidden) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) - { - //return db.Query(@"DECLARE @limit INT - // IF ((SELECT COUNT(*) FROM Payments p WHERE p.DepartmentId = @departmentId) >= 1) - // BEGIN - // SET @limit = (SELECT TOP 1 (pl.LimitValue * p.Quantity) FROM Payments p - // INNER JOIN PlanLimits pl ON pl.PlanId = p.PlanId - // WHERE DepartmentId = @departmentId AND pl.LimitType = 1 AND p.EffectiveOn <= GETUTCDATE() AND p.EndingOn >= GETUTCDATE() - // ORDER BY PaymentId DESC) - // END - // ELSE - // BEGIN - // SET @limit = 10 - // END - - // SELECT TOP (@limit) u.* FROM AspNetUsers u - // INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id - // WHERE dm.DepartmentId = @departmentId AND dm.IsDeleted = 0 AND (@retrieveHidden = 1 OR (dm.IsHidden = 0 OR dm.IsHidden IS NULL)) AND (dm.IsDisabled = 0 OR dm.IsDisabled IS NULL)", - // new { departmentId = departmentId, retrieveHidden = retrieveHidden }).ToList(); - - return db.Query(@"SELECT u.* FROM AspNetUsers u + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query(@"SELECT u.* FROM aspnetusers u + INNER JOIN departmentmembers dm ON dm.userid = u.id + WHERE dm.departmentid = @departmentId AND dm.isdeleted = 0 AND (@retrieveHidden = 1 OR (dm.ishidden = 0 OR dm.ishidden IS NULL)) AND (dm.isdisabled = 0 OR dm.isdisabled IS NULL)", + new { departmentId = departmentId, retrieveHidden = retrieveHidden }).ToList(); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id WHERE dm.DepartmentId = @departmentId AND dm.IsDeleted = 0 AND (@retrieveHidden = 1 OR (dm.IsHidden = 0 OR dm.IsHidden IS NULL)) AND (dm.IsDisabled = 0 OR dm.IsDisabled IS NULL)", - new { departmentId = departmentId, retrieveHidden = retrieveHidden }).ToList(); + new { departmentId = departmentId, retrieveHidden = retrieveHidden }).ToList(); + } } return null; @@ -194,32 +322,29 @@ public List GetAllUsersForDepartmentWithinLimits(int departmentId, public async Task> GetAllUsersForDepartmentWithinLimitsAsync(int departmentId, bool retrieveHidden) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) - { - //var result = await db.QueryAsync(@"DECLARE @limit INT - // IF ((SELECT COUNT(*) FROM Payments p WHERE p.DepartmentId = @departmentId) >= 1) - // BEGIN - // SET @limit = (SELECT TOP 1 (pl.LimitValue * p.Quantity) FROM Payments p - // INNER JOIN PlanLimits pl ON pl.PlanId = p.PlanId - // WHERE DepartmentId = @departmentId AND pl.LimitType = 1 AND p.EffectiveOn <= GETUTCDATE() AND p.EndingOn >= GETUTCDATE() - // ORDER BY PaymentId DESC) - // END - // ELSE - // BEGIN - // SET @limit = 10 - // END - - // SELECT TOP (@limit) u.* FROM AspNetUsers u - // INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id - // WHERE dm.DepartmentId = @departmentId AND dm.IsDeleted = 0 AND (@retrieveHidden = 1 OR (dm.IsHidden = 0 OR dm.IsHidden IS NULL)) AND (dm.IsDisabled = 0 OR dm.IsDisabled IS NULL)", - // new { departmentId = departmentId, retrieveHidden = retrieveHidden }); - - var result = await db.QueryAsync(@"SELECT u.* FROM AspNetUsers u + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var result = await db.QueryAsync(@"SELECT u.* FROM aspnetusers u + INNER JOIN departmentmembers dm ON dm.userid = u.id + WHERE dm.departmentid = @departmentId AND dm.isdeleted = 0 AND (@retrieveHidden = 1 OR (dm.ishidden = 0 OR dm.ishidden IS NULL)) AND (dm.isdisabled = 0 OR dm.isdisabled IS NULL)", + new { departmentId = departmentId, retrieveHidden = retrieveHidden }); + + return result.ToList(); + } + } + else + { + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + var result = await db.QueryAsync(@"SELECT u.* FROM AspNetUsers u INNER JOIN DepartmentMembers dm ON dm.UserId = u.Id WHERE dm.DepartmentId = @departmentId AND dm.IsDeleted = 0 AND (@retrieveHidden = 1 OR (dm.IsHidden = 0 OR dm.IsHidden IS NULL)) AND (dm.IsDisabled = 0 OR dm.IsDisabled IS NULL)", - new { departmentId = departmentId, retrieveHidden = retrieveHidden }); + new { departmentId = departmentId, retrieveHidden = retrieveHidden }); - return result.ToList(); + return result.ToList(); + } } return null; @@ -227,12 +352,25 @@ public async Task> GetAllUsersForDepartmentWithinLimitsAsync( public List GetAllUsersCreatedAfterTimestamp(DateTime timestamp) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + return db.Query(@"SELECT u.*, ue.* FROM aspnetusers u + INNER JOIN aspnetusersext ue ON u.id = ue.userid + WHERE ue.createdate > @timestamp", + new { timestamp = timestamp }).ToList(); + } + } + else { - return db.Query(@"SELECT u.*, ue.* FROM AspNetUsers u + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + return db.Query(@"SELECT u.*, ue.* FROM AspNetUsers u INNER JOIN AspNetUsersExt ue ON u.Id = ue.UserId WHERE ue.CreateDate > @timestamp", - new { timestamp = timestamp }).ToList(); + new { timestamp = timestamp }).ToList(); + } } return null; @@ -240,9 +378,32 @@ public List GetAllUsersCreatedAfterTimestamp(DateTime timestamp) public async Task> GetAllUsersGroupsAndRolesAsync(int departmentId, bool retrieveHidden, bool retrieveDisabled, bool retrieveDeleted) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) { - var query = await db.QueryAsync(@"SELECT dgm.DepartmentGroupId, u.Id as 'UserId', + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var query = await db.QueryAsync(@"SELECT dgm.departmentGroupid, u.id as userid, + (SELECT STRING_AGG(pru.personnelroleid::text, ',') FROM public.personnelroleusers pru WHERE pru.userid = u.id AND pru.departmentid = @departmentId) as roles, + (SELECT STRING_AGG(pr.name, ', ') FROM public.personnelroleusers pru INNER JOIN public.personnelroles pr ON pr.personnelroleid = pru.personnelroleid WHERE pru.userid = u.id AND pru.departmentid = @departmentId) as rolenames, + dg.name as departmentgroupname, + up.firstname AS firstname, + up.lastname AS lastname + FROM public.departmentmembers dm + INNER JOIN public.aspnetusers u ON u.id = dm.userid + LEFT OUTER JOIN public.departmentgroupmembers dgm ON u.id = dgm.userid AND dgm.departmentid = @departmentId + LEFT OUTER JOIN public.departmentgroups dg ON dg.departmentgroupid = dgm.departmentgroupid + INNER JOIN public.userprofiles up ON up.userid = u.id + WHERE dm.departmentid = @departmentId AND (@retrieveHidden = true OR (dm.ishidden = false OR dm.ishidden IS NULL)) AND (@retrieveDisabled = true OR (dm.isdisabled = false OR dm.isdisabled IS NULL)) AND (@retrieveDeleted = true OR (dm.isdeleted = false OR dm.isdeleted IS NULL)) + GROUP BY dgm.departmentgroupid, u.id, dg.name, up.firstname, up.lastname", + new { departmentId = departmentId, retrieveHidden = retrieveHidden, retrieveDisabled = retrieveDisabled, retrieveDeleted = retrieveDeleted }); + + return query.ToList(); + } + } + else + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + var query = await db.QueryAsync(@"SELECT dgm.DepartmentGroupId, u.Id as 'UserId', (SELECT STUFF(( SELECT ',' + CONVERT(varchar, pru.PersonnelRoleId) FROM PersonnelRoleUsers pru @@ -263,19 +424,30 @@ FROM DepartmentMembers dm LEFT OUTER JOIN DepartmentGroups dg ON dg.DepartmentGroupId = dgm.DepartmentGroupId INNER JOIN UserProfiles up ON up.UserId = u.Id WHERE dm.DepartmentId = @departmentId AND (@retrieveHidden = 1 OR (dm.IsHidden = 0 OR dm.IsHidden IS NULL)) AND (@retrieveDisabled = 1 OR (dm.IsDisabled = 0 OR dm.IsDisabled IS NULL)) AND (@retrieveDeleted = 1 OR (dm.IsDeleted = 0 OR dm.IsDeleted IS NULL))", - new { departmentId = departmentId, retrieveHidden = retrieveHidden, retrieveDisabled = retrieveDisabled, retrieveDeleted = retrieveDeleted }); + new { departmentId = departmentId, retrieveHidden = retrieveHidden, retrieveDisabled = retrieveDisabled, retrieveDeleted = retrieveDeleted }); - return query.ToList(); - } + return query.ToList(); + } } public async Task CleanUpOIDCTokensAsync(DateTime timestamp) { - using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + if (OidcConfig.DatabaseType == DatabaseTypes.Postgres) { - var result = await db.ExecuteAsync(@"DELETE FROM OpenIddictTokens + using (IDbConnection db = new NpgsqlConnection(OidcConfig.ConnectionString)) + { + var result = await db.ExecuteAsync(@"DELETE FROM public.openiddicttokens WHERE expirationdate < @timestamp", + new { timestamp = timestamp }); + } + } + else + { + using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + { + var result = await db.ExecuteAsync(@"DELETE FROM OpenIddictTokens WHERE ExpirationDate < @timestamp", - new { timestamp = timestamp }); + new { timestamp = timestamp }); + } } return false; @@ -283,13 +455,27 @@ public async Task CleanUpOIDCTokensAsync(DateTime timestamp) public async Task ClearOutUserLoginAsync(string userId) { - using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(DataConfig.CoreConnectionString)) + { + var result = await db.ExecuteAsync(@"UPDATE public.aspnetusers + SET username = @deleteid, + email = @deleteid + '@resgrid.del' + WHERE id = @userId", + new { userId = userId, deleteid = Guid.NewGuid().ToString() }); + } + } + else { - var result = await db.ExecuteAsync(@"UPDATE AspNetUsers + using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString)) + { + var result = await db.ExecuteAsync(@"UPDATE AspNetUsers SET UserName = @deleteid, Email = @deleteid + '@resgrid.del' WHERE Id = @userId", - new { userId = userId, deleteid = Guid.NewGuid().ToString() }); + new { userId = userId, deleteid = Guid.NewGuid().ToString() }); + } } return false; @@ -297,11 +483,22 @@ public async Task ClearOutUserLoginAsync(string userId) public async Task CleanUpOIDCTokensByUserAsync(string userId) { - using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + if (OidcConfig.DatabaseType == DatabaseTypes.Postgres) + { + using (IDbConnection db = new NpgsqlConnection(OidcConfig.ConnectionString)) + { + var result = await db.ExecuteAsync(@"DELETE FROM public.openiddicttokens WHERE subject = @userId", + new { userId = userId }); + } + } + else { - var result = await db.ExecuteAsync(@"DELETE FROM OpenIddictTokens + using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + { + var result = await db.ExecuteAsync(@"DELETE FROM OpenIddictTokens WHERE Subject = @userId", - new { userId = userId }); + new { userId = userId }); + } } return false; diff --git a/Repositories/Resgrid.Repositories.DataRepository/IdentityRoleRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/IdentityRoleRepository.cs index b57fceed..466565af 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/IdentityRoleRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/IdentityRoleRepository.cs @@ -36,7 +36,7 @@ public async Task GetByIdAsync(string id) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("IdValue", id); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task GetByNameAsync(string roleName) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Name", roleName); var query = _queryFactory.GetQuery(); @@ -117,7 +117,7 @@ public async Task> GetClaimsByRole(IdentityRole r { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("RoleId", role.Id); var query = _queryFactory.GetQuery(); @@ -240,7 +240,7 @@ public async Task RemoveAsync(string id, CancellationToken cancellationTok { var removeFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("IdValue", id); var query = _queryFactory.GetDeleteQuery(); @@ -280,7 +280,7 @@ public async Task RemoveClaimAsync(IdentityRole role, Claim claim, Cancell { var removeFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("RoleId", role.Id); dynamicParameters.Add("ClaimType", claim.Type); dynamicParameters.Add("ClaimValue", claim.Value); diff --git a/Repositories/Resgrid.Repositories.DataRepository/IdentityUserRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/IdentityUserRepository.cs index 1d5529d8..65261de8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/IdentityUserRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/IdentityUserRepository.cs @@ -49,7 +49,7 @@ public async Task GetByEmailAsync(string email) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Email", email); var query = _queryFactory.GetQuery(); @@ -97,7 +97,7 @@ public async Task GetByIdAsync(string id) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Id", id); var query = _queryFactory.GetQuery(); @@ -147,7 +147,7 @@ public async Task GetByUserNameAsync(string userName) { try { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserName", userName); var query = _queryFactory.GetQuery(); @@ -447,7 +447,7 @@ public async Task RemoveAsync(string id, CancellationToken cancellationTok { try { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Id", id); var query = _queryFactory.GetDeleteQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/InventoryRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/InventoryRepository.cs index 8d448c35..8f36782d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/InventoryRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/InventoryRepository.cs @@ -37,7 +37,7 @@ public async Task> GetInventoryByTypeIdAsync(int typeId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("TypeId", typeId); var query = _queryFactory.GetQuery(); @@ -78,7 +78,7 @@ public async Task> GetAllInventoriesByDepartmentIdAsync(i { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -121,7 +121,7 @@ public async Task GetInventoryByIdAsync(int inventoryId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("InventoryId", inventoryId); var query = _queryFactory.GetQuery(); @@ -166,7 +166,7 @@ public async Task GetInventoryByIdAsync(int inventoryId) { try { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", groupId); dynamicParameters.Add("DepartmentId", departmentId); diff --git a/Repositories/Resgrid.Repositories.DataRepository/InvitesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/InvitesRepository.cs index 09d0255b..e9a4dee6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/InvitesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/InvitesRepository.cs @@ -34,7 +34,7 @@ public async Task GetInviteByCodeAsync(Guid code) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Code", code); var query = _queryFactory.GetQuery(); @@ -75,7 +75,7 @@ public async Task GetInviteByEmailAsync(string emailAddress) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("EmailAddress", emailAddress); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/LogAttachmentRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/LogAttachmentRepository.cs index bab9ddb7..1be94fb3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/LogAttachmentRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/LogAttachmentRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAttachmentsByLogIdAsync(int log { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("LogId", logId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/LogUnitsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/LogUnitsRepository.cs index 4b8e1b09..9a3c6131 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/LogUnitsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/LogUnitsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetLogsByLogIdAsync(int logId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("LogId", logId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/LogUsersRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/LogUsersRepository.cs index 60049db5..fb7e5799 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/LogUsersRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/LogUsersRepository.cs @@ -35,7 +35,7 @@ public async Task> GetLogsForUserAsync(string userId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task> GetLogsByLogIdAsync(int logId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("LogId", logId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/LogsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/LogsRepository.cs index 12817640..e09bb512 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/LogsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/LogsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetLogsForUserAsync(string userId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task> GetLogsForCallAsync(int callId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); @@ -117,7 +117,7 @@ public async Task> GetLogsForGroupAsync(int groupId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", groupId); var query = _queryFactory.GetQuery(); @@ -158,7 +158,7 @@ public async Task> SelectLogYearsByDeptAsync(int departmentI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -199,9 +199,9 @@ public async Task> GetAllLogsByDepartmentIdYearAsync(int depart { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); - dynamicParameters.Add("Year", year); + dynamicParameters.Add("Year", int.Parse(year)); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/MessageRecipientRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/MessageRecipientRepository.cs index 44f868ef..bf1026c9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/MessageRecipientRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/MessageRecipientRepository.cs @@ -35,7 +35,7 @@ public async Task GetMessageRecipientByMessageAndUserAsync(int { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("MessageId", messageId); dynamicParameters.Add("UserId", userId); @@ -77,7 +77,7 @@ public async Task> GetMessageRecipientByUserAsync( { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/MessageRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/MessageRepository.cs index d8e4b53c..bb4a7f93 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/MessageRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/MessageRepository.cs @@ -37,7 +37,7 @@ public async Task GetUnreadMessageCountAsync(string userId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -122,7 +122,7 @@ public async Task GetMessagesByMessageIdAsync(int messageId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("MessageId", messageId); var query = _queryFactory.GetQuery(); @@ -170,7 +170,7 @@ public async Task> GetInboxMessagesByUserIdAsync(string use { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -218,7 +218,7 @@ public async Task> GetSentMessagesByUserIdAsync(string user { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -266,7 +266,7 @@ public async Task> GetMessagesByUserSendRecIdAsync(string u { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -328,11 +328,11 @@ public async Task UpdateRecievedMessagesAsDeletedAsync(string userId, List var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); - query = query.Replace("%MESSAGEIDS%", ids.ToString()); + query = query.Replace("%MESSAGEIDS%", ids.ToString(), StringComparison.InvariantCultureIgnoreCase); var result = await x.QueryAsync(sql: query, param: dynamicParameters, @@ -386,12 +386,12 @@ public async Task UpdateRecievedMessagesAsReadAsync(string userId, List>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("ReadOn", DateTime.UtcNow); var query = _queryFactory.GetQuery(); - query = query.Replace("%MESSAGEIDS%", ids.ToString()); + query = query.Replace("%MESSAGEIDS%", ids.ToString(), StringComparison.InvariantCultureIgnoreCase); var result = await x.QueryAsync(sql: query, param: dynamicParameters, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Modules/ApiDataModule.cs b/Repositories/Resgrid.Repositories.DataRepository/Modules/ApiDataModule.cs index 0002f2c1..7b20306d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Modules/ApiDataModule.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Modules/ApiDataModule.cs @@ -5,6 +5,7 @@ using Resgrid.Model.Repositories.Queries.Contracts; using Resgrid.Repositories.DataRepository.Configs; using Resgrid.Repositories.DataRepository.Queries; +using Resgrid.Repositories.DataRepository.Servers.PostgreSql; using Resgrid.Repositories.DataRepository.Servers.SqlServer; using Resgrid.Repositories.DataRepository.Transactions; @@ -16,6 +17,14 @@ protected override void Load(ContainerBuilder builder) { builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + // Custom Repositories builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); @@ -49,12 +58,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Modules/DataModule.cs b/Repositories/Resgrid.Repositories.DataRepository/Modules/DataModule.cs index ecb3ac38..c25f77c7 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Modules/DataModule.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Modules/DataModule.cs @@ -5,6 +5,7 @@ using Resgrid.Model.Repositories.Queries.Contracts; using Resgrid.Repositories.DataRepository.Configs; using Resgrid.Repositories.DataRepository.Queries; +using Resgrid.Repositories.DataRepository.Servers.PostgreSql; using Resgrid.Repositories.DataRepository.Servers.SqlServer; using Resgrid.Repositories.DataRepository.Transactions; @@ -16,6 +17,14 @@ protected override void Load(ContainerBuilder builder) { builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + // Custom Repositories builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); @@ -49,12 +58,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Modules/NonWebDataModule.cs b/Repositories/Resgrid.Repositories.DataRepository/Modules/NonWebDataModule.cs index 7d70ec61..70d0a5c6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Modules/NonWebDataModule.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Modules/NonWebDataModule.cs @@ -5,6 +5,7 @@ using Resgrid.Model.Repositories.Queries.Contracts; using Resgrid.Repositories.DataRepository.Configs; using Resgrid.Repositories.DataRepository.Queries; +using Resgrid.Repositories.DataRepository.Servers.PostgreSql; using Resgrid.Repositories.DataRepository.Servers.SqlServer; using Resgrid.Repositories.DataRepository.Transactions; @@ -16,6 +17,14 @@ protected override void Load(ContainerBuilder builder) { builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + // Custom Repositories builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); @@ -49,12 +58,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Modules/TestingDataModule.cs b/Repositories/Resgrid.Repositories.DataRepository/Modules/TestingDataModule.cs index eddc3aee..18e42e4f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Modules/TestingDataModule.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Modules/TestingDataModule.cs @@ -5,6 +5,7 @@ using Resgrid.Model.Repositories.Queries.Contracts; using Resgrid.Repositories.DataRepository.Configs; using Resgrid.Repositories.DataRepository.Queries; +using Resgrid.Repositories.DataRepository.Servers.PostgreSql; using Resgrid.Repositories.DataRepository.Servers.SqlServer; using Resgrid.Repositories.DataRepository.Transactions; @@ -16,6 +17,14 @@ protected override void Load(ContainerBuilder builder) { builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + //builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + // Custom Repositories builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); @@ -49,12 +58,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); - - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/NotesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/NotesRepository.cs index d62d828a..06f24e8c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/NotesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/NotesRepository.cs @@ -36,7 +36,7 @@ public async Task> GetNotesByDepartmentIdAsync(int departmentI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/OidcRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/OidcRepository.cs index fff00dc7..fa3cb7b8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/OidcRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/OidcRepository.cs @@ -6,49 +6,92 @@ using System.IO; using Resgrid.Providers.Migrations.Migrations; using System; -using DnsClient; -using Serilog.Core; +using Resgrid.Providers.MigrationsPg.Migrations; +using Npgsql; +using System.Threading.Tasks; namespace Resgrid.Repositories.DataRepository { public class OidcRepository : IOidcRepository { - public bool UpdateOidcDatabase() + public async Task UpdateOidcDatabaseAsync() { try { - var assembly = typeof(M0001_InitialMigration).Assembly; - - // Initial Migration - var resourceName = "Resgrid.Providers.Migrations.Sql.EF0001_PopulateOIDCDb.sql"; - - using (Stream stream = assembly.GetManifestResourceStream(resourceName)) - using (StreamReader reader = new StreamReader(stream)) + if (Config.DataConfig.DatabaseType == DatabaseTypes.Postgres) { - string migrationScript = reader.ReadToEnd(); + var assembly = typeof(M0001_InitialMigrationPg).Assembly; - if (!string.IsNullOrWhiteSpace(migrationScript)) + // Initial Migration + var resourceName = "Resgrid.Providers.MigrationsPg.Sql.EF0001_PopulateOIDCDb.sql"; + + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + using (StreamReader reader = new StreamReader(stream)) { - using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + string migrationScript = reader.ReadToEnd(); + + if (!string.IsNullOrWhiteSpace(migrationScript)) { - var response = db.Execute(migrationScript); + using (var conn = new NpgsqlConnection(OidcConfig.ConnectionString)) + using (var cmd = conn.CreateCommand()) + { + { + await conn.OpenAsync(); + using (var tran = conn.BeginTransaction()) + { + try + { + cmd.Transaction = tran; + cmd.CommandText = migrationScript; + await cmd.ExecuteNonQueryAsync(); + await tran.CommitAsync(); + } + catch + { + await tran.RollbackAsync(); + throw; + } + } + } + } } } } + else + { + var assembly = typeof(M0001_InitialMigration).Assembly; - // Update to V5 - var resourceName2 = "Resgrid.Providers.Migrations.Sql.EF0003_MigrateOIDCDbToV5.sql"; + // Initial Migration + var resourceName = "Resgrid.Providers.Migrations.Sql.EF0001_PopulateOIDCDb.sql"; - using (Stream stream = assembly.GetManifestResourceStream(resourceName2)) - using (StreamReader reader = new StreamReader(stream)) - { - string migrationScript = reader.ReadToEnd(); + using (Stream stream = assembly.GetManifestResourceStream(resourceName)) + using (StreamReader reader = new StreamReader(stream)) + { + string migrationScript = reader.ReadToEnd(); - if (!string.IsNullOrWhiteSpace(migrationScript)) + if (!string.IsNullOrWhiteSpace(migrationScript)) + { + using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + { + var response = await db.ExecuteAsync(migrationScript); + } + } + } + + // Update to V5 + var resourceName2 = "Resgrid.Providers.Migrations.Sql.EF0003_MigrateOIDCDbToV5.sql"; + + using (Stream stream = assembly.GetManifestResourceStream(resourceName2)) + using (StreamReader reader = new StreamReader(stream)) { - using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + string migrationScript = reader.ReadToEnd(); + + if (!string.IsNullOrWhiteSpace(migrationScript)) { - var response = db.Execute(migrationScript); + using (IDbConnection db = new SqlConnection(OidcConfig.ConnectionString)) + { + var response = await db.ExecuteAsync(migrationScript); + } } } } diff --git a/Repositories/Resgrid.Repositories.DataRepository/PaymentRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PaymentRepository.cs index f25d4ad8..a0d098b3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PaymentRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PaymentRepository.cs @@ -37,7 +37,7 @@ public async Task GetDepartmentPlanCountsByDepartmentIdAsyn { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -78,7 +78,7 @@ public async Task GetPaymentByTransactionIdAsync(string transactionId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("TransactionId", transactionId); var query = _queryFactory.GetQuery(); @@ -119,7 +119,7 @@ public async Task> GetAllPaymentsByDepartmentIdAsync(int de { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -162,7 +162,7 @@ public async Task GetPaymentByIdIdAsync(int paymentId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("PaymentId", paymentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/PermissionsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PermissionsRepository.cs index f0c80845..221f7362 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PermissionsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PermissionsRepository.cs @@ -34,7 +34,7 @@ public async Task GetPermissionByDepartmentTypeAsync(int departmentI { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("Type", type); diff --git a/Repositories/Resgrid.Repositories.DataRepository/PersonnelCertificationRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PersonnelCertificationRepository.cs index 0d02eaf9..3a49d1fd 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PersonnelCertificationRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PersonnelCertificationRepository.cs @@ -35,7 +35,7 @@ public async Task> GetCertificationsByUserAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/PersonnelRoleUsersRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PersonnelRoleUsersRepository.cs index 5c6b8a27..333026a4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PersonnelRoleUsersRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PersonnelRoleUsersRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllRoleUsersForUserAsync(in { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("UserId", userId); @@ -77,7 +77,7 @@ public async Task> GetAllMembersOfRoleAsync(int r { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("RoleId", roleId); var query = _queryFactory.GetQuery(); @@ -118,7 +118,7 @@ public async Task> GetAllRoleUsersForDepartmentAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/PersonnelRolesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PersonnelRolesRepository.cs index 8cd8ff3d..f976654d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PersonnelRolesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PersonnelRolesRepository.cs @@ -36,7 +36,7 @@ public async Task GetRoleByDepartmentAndNameAsync(int departmentI { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("Name", name); @@ -78,7 +78,7 @@ public async Task> GetRolesForUserAsync(int departmen { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("UserId", userId); @@ -120,7 +120,7 @@ public async Task GetRoleByRoleIdAsync(int personnelRoleId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("RoleId", personnelRoleId); var query = _queryFactory.GetQuery(); @@ -169,7 +169,7 @@ public async Task> GetPersonnelRolesByDepartmentIdAsy { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/PlansRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PlansRepository.cs index 80821af4..9add8e31 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PlansRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PlansRepository.cs @@ -36,7 +36,7 @@ public async Task GetPlanByPlanIdAsync(int planId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("PlanId", planId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/PoiTypesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/PoiTypesRepository.cs index 671e795f..e9da7c44 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/PoiTypesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/PoiTypesRepository.cs @@ -36,7 +36,7 @@ public async Task> GetPoiTypesByDepartmentIdAsync(int depar { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -84,7 +84,7 @@ public async Task GetPoiTypeByTypeIdAsync(int poiTypeId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("PoiTypeId", poiTypeId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDateRangeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDateRangeQuery.cs index 2227ca0d..a79ed57d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDateRangeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDateRangeQuery.cs @@ -17,7 +17,7 @@ public string GetQuery() { var query = _sqlConfiguration.SelectALogsByDateRangeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDidQuery.cs index e28fabfe..7b782486 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByDidQuery.cs @@ -17,7 +17,7 @@ public string GetQuery() { var query = _sqlConfiguration.SelectALogsByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByUserInDateRangQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByUserInDateRangQuery.cs index 3c52899c..61aed0bf 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByUserInDateRangQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectALogsByUserInDateRangQuery.cs @@ -17,7 +17,7 @@ public string GetQuery() { var query = _sqlConfiguration.SelectALogsByUserInDateRangQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdQuery.cs index 6a126d1c..2102157c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectActionLogsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectActionLogsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdTypeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdTypeQuery.cs index 5a4f0588..6fe78e91 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdTypeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByCallIdTypeQuery.cs @@ -16,7 +16,7 @@ public SelectActionLogsByCallIdTypeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectActionLogsByCallIdTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByUserIdQuery.cs index 03b50601..bda37286 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectActionLogsByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectActionLogsByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectActionLogsByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogByUserIdQuery.cs index 65b21d23..ab5061d2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectLastActionLogByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastActionLogByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogForUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogForUserQuery.cs index 59e77bd1..4b79d19e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogForUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogForUserQuery.cs @@ -16,7 +16,7 @@ public SelectLastActionLogForUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastActionLogForUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogsForDepartmentQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogsForDepartmentQuery.cs index 064a06b9..ab8e7e53 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogsForDepartmentQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectLastActionLogsForDepartmentQuery.cs @@ -16,7 +16,7 @@ public SelectLastActionLogsForDepartmentQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastActionLogsForDepartmentQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectPerviousActionLogsByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectPerviousActionLogsByUserQuery.cs index 43af7c29..ff863a20 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectPerviousActionLogsByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ActionLogs/SelectPerviousActionLogsByUserQuery.cs @@ -16,7 +16,7 @@ public SelectPerviousActionLogsByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPreviousActionLogsByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/DeleteCalendarItemQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/DeleteCalendarItemQuery.cs index c146c22c..c10c34b0 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/DeleteCalendarItemQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/DeleteCalendarItemQuery.cs @@ -17,7 +17,7 @@ public DeleteCalendarItemQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteCalendarItemQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CalendarItemsTable, _sqlConfiguration.ParameterNotation, new string[] diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemAttendeeByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemAttendeeByUserQuery.cs index 8f8a66bf..84d20eac 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemAttendeeByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemAttendeeByUserQuery.cs @@ -16,7 +16,7 @@ public SelectCalendarItemAttendeeByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCalendarItemAttendeeByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CalendarItemAttendeesTable, _sqlConfiguration.ParameterNotation, new string[] { "%ID%", "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByDIdQuery.cs index 8d94dfff..4208e161 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectCalendarItemByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCalendarItemByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByIdQuery.cs index 321b38c7..28c44546 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemByIdQuery.cs @@ -16,7 +16,7 @@ public SelectCalendarItemByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCalendarItemByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByDateQuery.cs index bfc81d88..fa737d1e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByDateQuery.cs @@ -16,7 +16,7 @@ public SelectCalendarItemsByDateQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCalendarItemsByDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CalendarItemsTable, _sqlConfiguration.ParameterNotation, new string[] { "%STARTDATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByRecurrenceIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByRecurrenceIdQuery.cs index f64269e3..d8c4b835 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByRecurrenceIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calendar/SelectCalendarItemsByRecurrenceIdQuery.cs @@ -16,7 +16,7 @@ public SelectCalendarItemByRecurrenceIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCalendarItemByRecurrenceIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CalendarItemsTable, _sqlConfiguration.ParameterNotation, new string[] { "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByCallIdQuery.cs index d038367a..000655ef 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallDispatchesByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallDispatchesByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallDispatchesTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByGroupIdQuery.cs index 018f3796..e561e132 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallDispatchesByGroupIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallDispatchesByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallDispatchesByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallDispatchGroupsTable, _sqlConfiguration.ParameterNotation, new string[] { "%GROUPID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallGroupDispsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallGroupDispsByCallIdQuery.cs index add68f79..0b74cbae 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallGroupDispsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallGroupDispsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallGroupDispsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallGroupDispsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallDispatchGroupsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesBySourceCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesBySourceCallIdQuery.cs index bda3d500..04a4128d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesBySourceCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesBySourceCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallReferencesBySourceCallIdQuery(SqlConfiguration sqlConfigurat public string GetQuery() { var query = _sqlConfiguration.SelectAllCallReferencesBySourceCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesByTargetCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesByTargetCallIdQuery.cs index b7da365f..a1d13f0a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesByTargetCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallReferencesByTargetCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallReferencesByTargetCallIdQuery(SqlConfiguration sqlConfigurat public string GetQuery() { var query = _sqlConfiguration.SelectAllCallReferencesByTargetCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallRoleDispsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallRoleDispsByCallIdQuery.cs index 22c678b1..289fcaf5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallRoleDispsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallRoleDispsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallRoleDispsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallRoleDispsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallDispatchRolesTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallUnitDispsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallUnitDispsByCallIdQuery.cs index d7afb19b..01f6891e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallUnitDispsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallUnitDispsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallUnitDispsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallUnitDispsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallDispatchUnitsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidDateQuery.cs index 55c71c2c..601d466b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidDateQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallsByDidDateQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallsByDidDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%STARTDATE%", "%ENDDATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidLoggedOnQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidLoggedOnQuery.cs index e858054a..5d7f6200 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidLoggedOnQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllCallsByDidLoggedOnQuery.cs @@ -16,7 +16,7 @@ public SelectAllCallsByDidLoggedOnQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllCallsByDidLoggedOnQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%DATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidDateQuery.cs index 0d341401..a47683fc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidDateQuery.cs @@ -16,7 +16,7 @@ public SelectAllClosedCallsByDidDateQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllClosedCallsByDidDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidYearQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidYearQuery.cs index 310c85a1..d78c4bbc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidYearQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllClosedCallsByDidYearQuery.cs @@ -16,7 +16,7 @@ public SelectAllClosedCallsByDidYearQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllClosedCallsByDidYearQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%YEAR%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllOpenCallsByDidDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllOpenCallsByDidDateQuery.cs index 6d9eaaad..d6bdeaee 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllOpenCallsByDidDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectAllOpenCallsByDidDateQuery.cs @@ -16,7 +16,7 @@ public SelectAllOpenCallsByDidDateQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllOpenCallsByDidDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdQuery.cs index 87bae5f7..fa73a59c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectCallAttachmentByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallAttachmentByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallAttachmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdTypeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdTypeQuery.cs index ccc58c8e..72b34767 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdTypeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallAttachmentByCallIdTypeQuery.cs @@ -16,7 +16,7 @@ public SelectCallAttachmentByCallIdTypeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallAttachmentByCallIdTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallAttachmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%", "%TYPE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallNotesByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallNotesByCallIdQuery.cs index a82bd096..7cfca850 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallNotesByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallNotesByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectCallNotesByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallNotesByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallNotesTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallProtocolsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallProtocolsByCallIdQuery.cs index 1049d56c..723613eb 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallProtocolsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallProtocolsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectCallProtocolsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallProtocolsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallYearsByDeptQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallYearsByDeptQuery.cs index b20540c0..cf79241e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallYearsByDeptQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectCallYearsByDeptQuery.cs @@ -16,7 +16,7 @@ public SelectCallYearsByDeptQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallYearsByDeptQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDateQuery.cs index 75a23917..36f75c3a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDateQuery.cs @@ -16,7 +16,7 @@ public SelectNonDispatchedScheduledCallsByDateQuery(SqlConfiguration sqlConfigur public string GetQuery() { var query = _sqlConfiguration.SelectNonDispatchedScheduledCallsByDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%STARTDATE%", "%ENDDATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDidQuery.cs index 2e794948..b4afd3c2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/SelectNonDispatchedScheduledCallsByDidQuery.cs @@ -16,7 +16,7 @@ public SelectNonDispatchedScheduledCallsByDidQuery(SqlConfiguration sqlConfigura public string GetQuery() { var query = _sqlConfiguration.SelectNonDispatchedScheduledCallsByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/UpdateUserDispatchesAsSentQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/UpdateUserDispatchesAsSentQuery.cs index 2442b71a..9da486ff 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/UpdateUserDispatchesAsSentQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Calls/UpdateUserDispatchesAsSentQuery.cs @@ -16,7 +16,7 @@ public UpdateUserDispatchesAsSentQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.UpdateUserDispatchesAsSentQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%", "%USERIDS%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Certifications/SelectCertsByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Certifications/SelectCertsByUserQuery.cs index c1fdd39f..37d9b01d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Certifications/SelectCertsByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Certifications/SelectCertsByUserQuery.cs @@ -16,7 +16,7 @@ public SelectCertsByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCertsByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CertificationsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteMultipleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteMultipleQuery.cs index b16c5292..4aad715f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteMultipleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteMultipleQuery.cs @@ -21,7 +21,7 @@ public string GetQuery() public string GetQuery(TEntity entity) where TEntity : class, IEntity { var query = _sqlConfiguration.DeleteMultipleQuery. - ReplaceQueryParameters(_sqlConfiguration.SchemaName, + ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteQuery.cs index 8729a871..32059826 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/DeleteQuery.cs @@ -21,8 +21,8 @@ public string GetQuery() public string GetQuery(TEntity entity) where TEntity : class, IEntity { var query = _sqlConfiguration.DeleteQuery - .ReplaceDeleteQueryParameters(_sqlConfiguration.SchemaName, - ((IEntity)entity).TableName, + .ReplaceDeleteQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + ((IEntity)entity).TableName, ((IEntity)entity).IdName, $"{_sqlConfiguration.ParameterNotation}Id"); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/InsertQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/InsertQuery.cs index 6b534081..56b1faa9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/InsertQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/InsertQuery.cs @@ -33,7 +33,7 @@ public string GetQuery(TEntity entity) var query = _sqlConfiguration.InsertQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, ((IEntity)entity).TableName, returnId, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectAllQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectAllQuery.cs index b2c0dede..dc8e64a3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectAllQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectAllQuery.cs @@ -23,7 +23,7 @@ public string GetQuery() where TEntity : class, IEntity { var entity = Activator.CreateInstance(typeof(TEntity)); var query = _sqlConfiguration.SelectAllQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, ((IEntity)entity).TableName, _sqlConfiguration.ParameterNotation, new string[] { }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByDepartmentIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByDepartmentIdQuery.cs index 6fa422e7..71f15df1 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByDepartmentIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByDepartmentIdQuery.cs @@ -23,7 +23,7 @@ public string GetQuery() where TEntity : class, IEntity { var entity = Activator.CreateInstance(typeof(TEntity)); var query = _sqlConfiguration.SelectByDepartmentIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, ((IEntity)entity).TableName, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByIdQuery.cs index 8c40e81f..f1982b3a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByIdQuery.cs @@ -25,7 +25,7 @@ public string GetQuery() where TEntity : class, IEntity var query = _sqlConfiguration.SelectByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByUserIdQuery.cs index 66b271ce..769fefd5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/SelectByUserIdQuery.cs @@ -23,7 +23,7 @@ public string GetQuery() where TEntity : class, IEntity { var entity = Activator.CreateInstance(typeof(TEntity)); var query = _sqlConfiguration.SelectByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, ((IEntity)entity).TableName, _sqlConfiguration.ParameterNotation, new string[] { "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/UpdateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/UpdateQuery.cs index eaee1520..3bf9ee3f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/UpdateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Common/UpdateQuery.cs @@ -28,7 +28,7 @@ public string GetQuery(TEntity entity) var idName = ((IEntity)entity).IdName; var query = _sqlConfiguration.UpdateQuery - .ReplaceUpdateQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceUpdateQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, tableName, setFragment, idName, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByDidUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByDidUserQuery.cs index 107ac744..c2095d3c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByDidUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByDidUserQuery.cs @@ -16,7 +16,7 @@ public SelectStatesByDidUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectStatesByDidUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByIdQuery.cs index 73e4a9bb..e358ca5b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/CustomStates/SelectStatesByIdQuery.cs @@ -16,7 +16,7 @@ public SelectStatesByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectStatesByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/DeleteGroupMembersByGroupIdDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/DeleteGroupMembersByGroupIdDidQuery.cs index 2f67647b..4b49ed30 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/DeleteGroupMembersByGroupIdDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/DeleteGroupMembersByGroupIdDidQuery.cs @@ -17,7 +17,7 @@ public DeleteGroupMembersByGroupIdDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteGroupMembersByGroupIdDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentGroupMembersTable, _sqlConfiguration.ParameterNotation, new string[] diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByDidQuery.cs index 232efec9..632f0f88 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByDidQuery.cs @@ -16,7 +16,7 @@ public SelectAllGroupsByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllGroupsByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByParentIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByParentIdQuery.cs index dd256055..e5237775 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByParentIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectAllGroupsByParentIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllGroupsByParentIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllGroupsByParentIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupAdminsByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupAdminsByDidQuery.cs index 1379115b..544c2a11 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupAdminsByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupAdminsByDidQuery.cs @@ -16,7 +16,7 @@ public SelectGroupAdminsByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGroupAdminsByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByDispatchCodeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByDispatchCodeQuery.cs index b094165e..6f712230 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByDispatchCodeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByDispatchCodeQuery.cs @@ -16,7 +16,7 @@ public SelectGroupByDispatchCodeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGroupByDispatchCodeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByGroupIdQuery.cs index 45692a31..09d0329d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByGroupIdQuery.cs @@ -16,7 +16,7 @@ public SelectGroupByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGroupByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByMessageCodeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByMessageCodeQuery.cs index 6f0db55c..a769f9bc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByMessageCodeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupByMessageCodeQuery.cs @@ -16,7 +16,7 @@ public SelectGroupByMessageCodeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGroupByMessageCodeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByGroupIdQuery.cs index 2417ea82..ab99c5d2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByGroupIdQuery.cs @@ -2,6 +2,9 @@ using Resgrid.Model.Repositories.Queries.Contracts; using Resgrid.Repositories.DataRepository.Configs; using Resgrid.Repositories.DataRepository.Extensions; +using static Resgrid.Framework.Testing.TestData; +using Stripe; +using System.Text.RegularExpressions; namespace Resgrid.Repositories.DataRepository.Queries.DepartmentGroups { @@ -16,7 +19,7 @@ public SelectGroupMembersByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGroupMembersByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { @@ -35,7 +38,7 @@ public string GetQuery() _sqlConfiguration.DepartmentGroupMembersTable, _sqlConfiguration.DepartmentMembersTable } - ); + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByUserDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByUserDidQuery.cs index 3126e1b1..a3088153 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByUserDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentGroups/SelectGroupMembersByUserDidQuery.cs @@ -16,7 +16,7 @@ public SelectGroupMembersByUserDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGroupMembersByUserDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinkForDepartmentIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinkForDepartmentIdQuery.cs index 34e978e2..d3e8d7ad 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinkForDepartmentIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinkForDepartmentIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllLinkForDepartmentIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllLinkForDepartmentIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentLinksTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinksForDepartmentQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinksForDepartmentQuery.cs index 6fde1f00..0506fb2a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinksForDepartmentQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentLinks/SelectAllLinksForDepartmentQuery.cs @@ -16,7 +16,7 @@ public SelectAllLinksForDepartmentQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllLinksForDepartmentQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentLinksTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByDidUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByDidUserIdQuery.cs index b761316b..be2d7a36 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByDidUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByDidUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectMembersByDidUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMembersByDidUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByUserIdQuery.cs index ced7a918..4d2282cb 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectMembersByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMembersByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedInclDelQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedInclDelQuery.cs index d245c9e8..1bfa3b66 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedInclDelQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedInclDelQuery.cs @@ -16,7 +16,7 @@ public SelectMembersUnlimitedInclDelQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMembersUnlimitedInclDelQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedQuery.cs index 6a94b95a..33cb0940 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersUnlimitedQuery.cs @@ -16,7 +16,7 @@ public SelectMembersUnlimitedQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMembersUnlimitedQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersWithinLimitsQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersWithinLimitsQuery.cs index 8e090522..e4201eea 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersWithinLimitsQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentMembers/SelectMembersWithinLimitsQuery.cs @@ -16,7 +16,7 @@ public SelectMembersWithinLimitsQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMembersWithinLimitsQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectAllManagerInfoQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectAllManagerInfoQuery.cs index c8a66670..7a0b3154 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectAllManagerInfoQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectAllManagerInfoQuery.cs @@ -16,11 +16,24 @@ public SelectAllManagerInfoQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllDepartmentManagerInfoQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.DepartmentSettingsTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { }, - new string[] { }); + new string[] { + + }, + new string[] { + + }, + new string[] { + "%DEPARTMENTSTABLE%", + "%ASPNETUSERSTABLE%" + }, + new string[] { + _sqlConfiguration.DepartmentsTable, + "AspNetUsers" + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingAndTypeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingAndTypeQuery.cs index 0bfbbd55..f228a22f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingAndTypeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingAndTypeQuery.cs @@ -16,7 +16,7 @@ public SelectBySettingAndTypeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentSettingBySettingAndTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentSettingsTable, _sqlConfiguration.ParameterNotation, new string[] { "%SETTING%", "%SETTINGTYPE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeDepartmentIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeDepartmentIdQuery.cs index c0540ab1..412bc7e9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeDepartmentIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeDepartmentIdQuery.cs @@ -16,7 +16,7 @@ public SelectBySettingTypeDepartmentIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentSettingByDepartmentIdTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentSettingsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%SETTINGTYPE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeUserIdQuery.cs index 50d41d7d..945e20be 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectBySettingTypeUserIdQuery.cs @@ -16,11 +16,26 @@ public SelectBySettingTypeUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentSettingByTypeUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.DepartmentSettingsTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { "%USERID%", "%SETTINGTYPE%" }, - new string[] { "UserId", "SettingType" }); + new string[] { + "%USERID%", + "%SETTINGTYPE%" + }, + new string[] { + "UserId", + "SettingType" + }, + new string[] { + "%DEPARTMENTSETTINGSTABLE%", + "%DEPARTMENTMEMBERSTABLE%" + }, + new string[] { + _sqlConfiguration.DepartmentSettingsTable, + _sqlConfiguration.DepartmentMembersTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectManagerInfoByEmailQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectManagerInfoByEmailQuery.cs index 5bbcb314..acee113c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectManagerInfoByEmailQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DepartmentSettings/SelectManagerInfoByEmailQuery.cs @@ -16,11 +16,26 @@ public SelectManagerInfoByEmailQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentManagerInfoByEmailQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.DepartmentSettingsTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { "%EMAILADDRESS%" }, - new string[] { "EmailAddress" }); + new string[] { + "%EMAILADDRESS%" + }, + new string[] { + "EmailAddress" + }, + new string[] { + "%DEPARTMENTSTABLE%", + "%ASPNETUSERSTABLE%", + "%USERPROFILESTABLE%", + }, + new string[] { + _sqlConfiguration.DepartmentsTable, + "AspNetUsers", + _sqlConfiguration.UserProfilesTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectCallPruningByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectCallPruningByDidQuery.cs index fb9653a6..6655339f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectCallPruningByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectCallPruningByDidQuery.cs @@ -16,7 +16,7 @@ public SelectCallPruningByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallPruningByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentCallPruningTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByIdQuery.cs index 925092da..9a129918 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByIdQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByLinkCodeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByLinkCodeQuery.cs index b1a1096f..00f2d70d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByLinkCodeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByLinkCodeQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentByLinkCodeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentByLinkCodeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByNameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByNameQuery.cs index 97d6142f..717f0fbc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByNameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByNameQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentByNameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentByNameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUserIdQuery.cs index 44e9d81c..94ff477e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUsernameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUsernameQuery.cs index 38433e43..3dba548c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUsernameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentByUsernameQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentByUsernameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentByUsernameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentReportByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentReportByDidQuery.cs index bb6468ae..a7414df0 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentReportByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentReportByDidQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentReportByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentReportByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentStatsByUserDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentStatsByUserDidQuery.cs index 7ddd1baf..cfaabac6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentStatsByUserDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectDepartmentStatsByUserDidQuery.cs @@ -16,7 +16,7 @@ public SelectDepartmentStatsByUserDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDepartmentStatsByUserDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectValidDepartmentByUsernameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectValidDepartmentByUsernameQuery.cs index 65d94dbc..5e24c95c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectValidDepartmentByUsernameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Departments/SelectValidDepartmentByUsernameQuery.cs @@ -16,7 +16,7 @@ public SelectValidDepartmentByUsernameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectValidDepartmentByUsernameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectAllEnabledDListsQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectAllEnabledDListsQuery.cs index 4559bb9e..62ebe729 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectAllEnabledDListsQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectAllEnabledDListsQuery.cs @@ -16,7 +16,7 @@ public SelectAllEnabledDListsQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllEnabledDListsQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DistributionListsTable, _sqlConfiguration.ParameterNotation, new string[] { }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByEmailQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByEmailQuery.cs index 79093821..a692c19d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByEmailQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByEmailQuery.cs @@ -16,7 +16,7 @@ public SelectDListByEmailQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDListByEmailQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DistributionListsTable, _sqlConfiguration.ParameterNotation, new string[] { "%EMAIL%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByIdQuery.cs index 9e79a527..42407fb3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListByIdQuery.cs @@ -16,7 +16,7 @@ public SelectDListByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDListByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByListIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByListIdQuery.cs index a31c6dc2..e4605a03 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByListIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByListIdQuery.cs @@ -16,7 +16,7 @@ public SelectDListMembersByListIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDListMembersByListIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DistributionListMembersTable, _sqlConfiguration.ParameterNotation, new string[] { "%LISTID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByUserQuery.cs index b9f302bc..82bed25a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListMembersByUserQuery.cs @@ -16,7 +16,7 @@ public SelectDListMembersByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDListMembersByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DistributionListsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListsByDIdQuery.cs index 6f1cd8ca..fa5d1355 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/DistributionLists/SelectDListsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectDListsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectDListsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormAutomationsByFormIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormAutomationsByFormIdQuery.cs index 45dad903..496702f8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormAutomationsByFormIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormAutomationsByFormIdQuery.cs @@ -16,7 +16,7 @@ public SelectFormAutomationsByFormIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectFormAutomationsByFormIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormByIdQuery.cs index 4fc593cb..98deda02 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormByIdQuery.cs @@ -16,7 +16,7 @@ public SelectFormByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectFormByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormsByDIdQuery.cs index b3ea8898..6617abd3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectFormsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectFormsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectFormsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectNonDeletedFormsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectNonDeletedFormsByDIdQuery.cs index 05d49003..e5e8e5de 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectNonDeletedFormsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/SelectNonDeletedFormsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectNonDeletedFormsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectNonDeletedFormsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToDisableQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToDisableQuery.cs index b46f7297..e600fef9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToDisableQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToDisableQuery.cs @@ -16,7 +16,7 @@ public UpdateFormsToDisableQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.UpdateFormsToDisableQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%FORMID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToEnableQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToEnableQuery.cs index 08fe20ab..cc453896 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToEnableQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Forms/UpdateFormsToEnableQuery.cs @@ -16,7 +16,7 @@ public UpdateFormsToEnableQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.UpdateFormsToEnableQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallsTable, _sqlConfiguration.ParameterNotation, new string[] { "%FORMID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleClaimQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleClaimQuery.cs index ff392bc7..6e88e817 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleClaimQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleClaimQuery.cs @@ -17,7 +17,7 @@ public DeleteRoleClaimQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteRoleClaimQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleClaimTable, _sqlConfiguration.ParameterNotation, new string[] diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleQuery.cs index 2c5691f2..a77f4cd2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/DeleteRoleQuery.cs @@ -17,7 +17,7 @@ public DeleteQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteRoleQuery - .ReplaceDeleteQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceDeleteQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleTable, "Id", // TODO: Me Fix -SJ $"{_sqlConfiguration.ParameterNotation}Id"); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/GetClaimsByRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/GetClaimsByRoleQuery.cs index e3e50579..dc0c0fb8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/GetClaimsByRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/GetClaimsByRoleQuery.cs @@ -17,7 +17,7 @@ public GetClaimsByRoleQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectClaimByRoleQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertClaimQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertClaimQuery.cs index 9a604e0a..8c521fd3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertClaimQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertClaimQuery.cs @@ -22,7 +22,7 @@ public string GetQuery(TEntity entity) valuesArray = valuesArray.InsertQueryValuesFragment(_sqlConfiguration.ParameterNotation, columns); var query = _sqlConfiguration.InsertRoleClaimQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleClaimTable, _sqlConfiguration.InsertGetReturnIdCommand, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertRoleQuery.cs index aa59676b..4997238a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/InsertRoleQuery.cs @@ -22,7 +22,7 @@ public string GetQuery(TEntity entity) valuesArray = valuesArray.InsertQueryValuesFragment(_sqlConfiguration.ParameterNotation, columns); var query = _sqlConfiguration.InsertRoleQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleTable, _sqlConfiguration.InsertGetReturnIdCommand, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByIdQuery.cs index cea7ec5d..a1af659f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByIdQuery.cs @@ -16,7 +16,7 @@ public SelectByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRoleByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleTable, _sqlConfiguration.ParameterNotation, new string[] { "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByNameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByNameQuery.cs index 8f93a8e5..a329f9a6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByNameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/SelectRoleByNameQuery.cs @@ -16,7 +16,7 @@ public SelectRoleByNameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRoleByNameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleTable, _sqlConfiguration.ParameterNotation, new string[] { "%NAME%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/UpdateRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/UpdateRoleQuery.cs index 1cbdfd8c..d0d3c91f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/UpdateRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/Role/UpdateRoleQuery.cs @@ -20,7 +20,7 @@ public string GetQuery(TEntity entity) var setFragment = roleProperties.UpdateQuerySetFragment(_sqlConfiguration.ParameterNotation); var query = _sqlConfiguration.UpdateRoleQuery - .ReplaceUpdateQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceUpdateQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleTable, setFragment, ((IEntity)entity).IdName, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/DeleteUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/DeleteUserQuery.cs index 01928c3b..aa0669d1 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/DeleteUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/DeleteUserQuery.cs @@ -17,7 +17,7 @@ public DeleteUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteUserQuery - .ReplaceDeleteQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceDeleteQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserTable, "Id", // TODO: Fix MEEEE! $"{_sqlConfiguration.ParameterNotation}Id"); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetClaimsByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetClaimsByUserIdQuery.cs index 2cbae6dc..f3d1f303 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetClaimsByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetClaimsByUserIdQuery.cs @@ -17,7 +17,7 @@ public GetClaimsByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.GetClaimsByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserClaimTable, _sqlConfiguration.ParameterNotation, new string[] { "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetRolesByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetRolesByUserIdQuery.cs index b4327643..57ddaf9f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetRolesByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetRolesByUserIdQuery.cs @@ -17,7 +17,7 @@ public GetRolesByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.GetRolesByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginByLoginProviderAndProviderKeyQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginByLoginProviderAndProviderKeyQuery.cs index c24ff404..e64ca3a2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginByLoginProviderAndProviderKeyQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginByLoginProviderAndProviderKeyQuery.cs @@ -25,7 +25,7 @@ public string GetQuery() where TEntity : class, IEntity var userProperties = entity.GetColumns(_sqlConfiguration, ignoreIdProperty: false, ignoreProperties: new string[] { "ConcurrencyStamp" }, forInsert: false); var query = _sqlConfiguration.GetUserLoginByLoginProviderAndProviderKeyQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginInfoByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginInfoByIdQuery.cs index 93ac7497..0e66beaa 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginInfoByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUserLoginInfoByIdQuery.cs @@ -17,7 +17,7 @@ public GetUserLoginInfoByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.GetUserLoginInfoByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserLoginTable, _sqlConfiguration.ParameterNotation, new string[] { "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersByClaimQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersByClaimQuery.cs index b242abff..cac8804f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersByClaimQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersByClaimQuery.cs @@ -25,7 +25,7 @@ public string GetQuery() where TEntity : class, IEntity var userProperties = entity.GetColumns(_sqlConfiguration, ignoreIdProperty: true, ignoreProperties: new string[] { "ConcurrencyStamp" }); var query = _sqlConfiguration.GetUsersByClaimQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserTable, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersInRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersInRoleQuery.cs index a8f07f5f..63e01f67 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersInRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/GetUsersInRoleQuery.cs @@ -25,7 +25,7 @@ public string GetQuery() where TEntity : class, IEntity var userProperties = entity.GetColumns(_sqlConfiguration, ignoreIdProperty: true, ignoreProperties: new string[] { "ConcurrencyStamp" }); var query = _sqlConfiguration.GetUsersInRoleQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserClaimQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserClaimQuery.cs index c2cbcc54..830d78c9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserClaimQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserClaimQuery.cs @@ -24,7 +24,7 @@ public string GetQuery(TEntity entity) valuesArray = valuesArray.InsertQueryValuesFragment(_sqlConfiguration.ParameterNotation, columns); var query = _sqlConfiguration.InsertUserClaimQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserClaimTable, _sqlConfiguration.InsertGetReturnIdCommand, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserLoginQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserLoginQuery.cs index 34184a12..c6a2c434 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserLoginQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserLoginQuery.cs @@ -23,7 +23,7 @@ public string GetQuery(TEntity entity) valuesArray = valuesArray.InsertQueryValuesFragment(_sqlConfiguration.ParameterNotation, columns); var query = _sqlConfiguration.InsertUserLoginQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserLoginTable, _sqlConfiguration.InsertGetReturnIdCommand, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserQuery.cs index 8169a81f..97c79998 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserQuery.cs @@ -24,7 +24,7 @@ public string GetQuery(TEntity entity) valuesArray = valuesArray.InsertQueryValuesFragment(_sqlConfiguration.ParameterNotation, columns); var query = _sqlConfiguration.InsertUserQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserTable, _sqlConfiguration.InsertGetReturnIdCommand, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserRoleQuery.cs index 39a2406b..5bba865f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/InsertUserRoleQuery.cs @@ -23,7 +23,7 @@ public string GetQuery(TEntity entity) valuesArray = valuesArray.InsertQueryValuesFragment(_sqlConfiguration.ParameterNotation, columns); var query = _sqlConfiguration.InsertUserRoleQuery - .ReplaceInsertQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceInsertQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserRoleTable, _sqlConfiguration.InsertGetReturnIdCommand, columns.GetCommaSeparatedColumns(), diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/IsInRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/IsInRoleQuery.cs index c9f01b01..0f3b69a4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/IsInRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/IsInRoleQuery.cs @@ -26,7 +26,7 @@ public string GetQuery() where TEntity : class, IEntity var userProperties = entity.GetColumns(_sqlConfiguration, ignoreIdProperty: true, ignoreProperties: new string[] { "ConcurrencyStamp" }); var query = _sqlConfiguration.IsInRoleQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserTable, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveClaimsQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveClaimsQuery.cs index c2cb721e..5111464c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveClaimsQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveClaimsQuery.cs @@ -17,7 +17,7 @@ public RemoveClaimsQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.RemoveClaimsQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserClaimTable, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveLoginForUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveLoginForUserQuery.cs index 332ef1e9..c7cd1a99 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveLoginForUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveLoginForUserQuery.cs @@ -17,7 +17,7 @@ public RemoveLoginForUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.RemoveLoginForUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserLoginTable, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveUserFromRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveUserFromRoleQuery.cs index 97cd1015..2fb96a7f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveUserFromRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/RemoveUserFromRoleQuery.cs @@ -17,7 +17,7 @@ public RemoveUserFromRoleQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.RemoveUserFromRoleQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserRoleTable, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByEmailQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByEmailQuery.cs index 798902de..7b5bb274 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByEmailQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByEmailQuery.cs @@ -17,7 +17,7 @@ public SelectUserByEmailQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUserByEmailQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByIdQuery.cs index 48de7c4d..eecea99b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByIdQuery.cs @@ -17,7 +17,7 @@ public SelectUserByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUserByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByUserNameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByUserNameQuery.cs index 03e64205..c33d546f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByUserNameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/SelectUserByUserNameQuery.cs @@ -17,7 +17,7 @@ public SelectUserByUserNameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUserByUserNameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateClaimForUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateClaimForUserQuery.cs index 6a5a7703..9a5f1ae3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateClaimForUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateClaimForUserQuery.cs @@ -16,7 +16,7 @@ public UpdateClaimForUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery(TEntity entity) { var query = _sqlConfiguration.UpdateClaimForUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserClaimTable, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateUserQuery.cs index 6d18fe70..373d6f0b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Identity/User/UpdateUserQuery.cs @@ -21,7 +21,7 @@ public string GetQuery(TEntity entity) var setFragment = roleProperties.UpdateQuerySetFragment(_sqlConfiguration.ParameterNotation); var query = _sqlConfiguration.UpdateUserQuery - .ReplaceUpdateQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceUpdateQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserTable, setFragment, ((IEntity)entity).IdName, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/DeleteInventoryByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/DeleteInventoryByGroupIdQuery.cs index 0a19ace7..d9437307 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/DeleteInventoryByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/DeleteInventoryByGroupIdQuery.cs @@ -17,7 +17,7 @@ public DeleteInventoryByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteInventoryByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.InventoryTable, _sqlConfiguration.ParameterNotation, new string[] diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByDIdQuery.cs index cbf0050f..a949aca3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectInventoryByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectInventoryByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByInventoryIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByInventoryIdQuery.cs index 4f94b279..17522a7b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByInventoryIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByInventoryIdQuery.cs @@ -16,7 +16,7 @@ public SelectInventoryByInventoryIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectInventoryByInventoryIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByTypeIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByTypeIdQuery.cs index 69f9440f..809ef74b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByTypeIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Inventory/SelectInventoryByTypeIdQuery.cs @@ -16,7 +16,7 @@ public SelectInventoryByTypeIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectInventoryByTypeIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.InventoryTable, _sqlConfiguration.ParameterNotation, new string[] { "%TYPEID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByCodeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByCodeQuery.cs index e9827665..2b622d1f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByCodeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByCodeQuery.cs @@ -16,7 +16,7 @@ public SelectInviteByCodeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectInviteByCodeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.InvitesTable, _sqlConfiguration.ParameterNotation, new string[] { "%CODE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByEmailQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByEmailQuery.cs index d34b6a18..e6ad0b00 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByEmailQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Invites/SelectInviteByEmailQuery.cs @@ -16,7 +16,7 @@ public SelectInviteByEmailQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectInviteByEmailQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.InvitesTable, _sqlConfiguration.ParameterNotation, new string[] { "%EMAIL%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelecAllLogsByDidYearQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelecAllLogsByDidYearQuery.cs index 79edc273..46df863b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelecAllLogsByDidYearQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelecAllLogsByDidYearQuery.cs @@ -16,7 +16,7 @@ public SelecAllLogsByDidYearQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelecAllLogsByDidYearQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%YEAR%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByCallIdQuery.cs index a2d91aea..4cc01afc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectCallLogsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallLogsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallLogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByUserIdQuery.cs index 4479ff5b..7b5dc04a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectCallLogsByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectCallLogsByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCallLogsByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.CallLogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogAttachmentByLogIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogAttachmentByLogIdQuery.cs index 24cb28e9..e14661a5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogAttachmentByLogIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogAttachmentByLogIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogAttachmentByLogIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogAttachmentByLogIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogAttachmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%LOGID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUnitsByLogIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUnitsByLogIdQuery.cs index 5dbba211..b50c0654 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUnitsByLogIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUnitsByLogIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogUnitsByLogIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogUnitsByLogIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByLogIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByLogIdQuery.cs index 747ec19f..821f6143 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByLogIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByLogIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogUsersByLogIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogUsersByLogIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogUsersTable, _sqlConfiguration.ParameterNotation, new string[] { "%LOGID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByUserIdQuery.cs index edc41c04..bf6908fc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogUsersByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogUsersByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogUsersByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogYearsByDeptQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogYearsByDeptQuery.cs index 6a039a92..31dd8c51 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogYearsByDeptQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogYearsByDeptQuery.cs @@ -16,7 +16,7 @@ public SelectLogYearsByDeptQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogYearsByDeptQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByCallIdQuery.cs index 95219b0d..fd2c5685 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogsByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogsByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%CALLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByGroupIdQuery.cs index 679dd883..7399af9e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByGroupIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogsByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogsByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%GROUPID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByUserIdQuery.cs index 68fbc167..ee1b4d9a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Logs/SelectLogsByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectLogsByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLogsByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.LogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypeByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypeByIdQuery.cs index 4c8f87dc..fd69e6f8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypeByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypeByIdQuery.cs @@ -16,7 +16,7 @@ public SelectPoiTypeByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPoiTypeByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypesByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypesByDIdQuery.cs index 5706ece1..1e0e90d5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypesByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Mapping/SelectPoiTypesByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectPoiTypesByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPoiTypesByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectInboxMessagesByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectInboxMessagesByUserQuery.cs index 232c07fd..f88a838e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectInboxMessagesByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectInboxMessagesByUserQuery.cs @@ -16,7 +16,7 @@ public SelectInboxMessagesByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectInboxMessagesByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageByIdQuery.cs index 666232f6..b96424e9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageByIdQuery.cs @@ -16,7 +16,7 @@ public SelectMessageByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMessageByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpByMessageUsQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpByMessageUsQuery.cs index c135119e..4152a8ae 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpByMessageUsQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpByMessageUsQuery.cs @@ -16,7 +16,7 @@ public SelectMessageRecpByMessageUsQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMessageRecpByMessageUsQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.MessageRecipientsTable, _sqlConfiguration.ParameterNotation, new string[] { "%MESSAGEID%", "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpsByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpsByUserQuery.cs index ae9a12ad..f4273398 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpsByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessageRecpsByUserQuery.cs @@ -16,7 +16,7 @@ public SelectMessageRecpsByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMessageRecpsByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.MessageRecipientsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessagesByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessagesByUserQuery.cs index 8480475b..5e6afc55 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessagesByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectMessagesByUserQuery.cs @@ -16,7 +16,7 @@ public SelectMessagesByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMessagesByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectSentMessagesByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectSentMessagesByUserQuery.cs index 7fbd5f30..840d3dd9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectSentMessagesByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectSentMessagesByUserQuery.cs @@ -16,7 +16,7 @@ public SelectSentMessagesByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectSentMessagesByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectUnreadMessageCountQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectUnreadMessageCountQuery.cs index 92e75208..8d2d315a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectUnreadMessageCountQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/SelectUnreadMessageCountQuery.cs @@ -16,7 +16,7 @@ public SelectUnreadMessageCountQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnreadMessageCountQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsDeletedQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsDeletedQuery.cs index ce8112ad..d612ee20 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsDeletedQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsDeletedQuery.cs @@ -16,7 +16,7 @@ public UpdateRecievedMessagesAsDeletedQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.UpdateRecievedMessagesAsDeletedQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.MessageRecipientsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsReadQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsReadQuery.cs index 356d9d87..ec622705 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsReadQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Messages/UpdateRecievedMessagesAsReadQuery.cs @@ -16,7 +16,7 @@ public UpdateRecievedMessagesAsReadQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.UpdateRecievedMessagesAsReadQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.MessageRecipientsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%", "%READON%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Notes/SelectNotesByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Notes/SelectNotesByDIdQuery.cs index 95398628..5d3a8210 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Notes/SelectNotesByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Notes/SelectNotesByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectNotesByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectNotesByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectGetDepartmentPlanCountsQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectGetDepartmentPlanCountsQuery.cs index fc20e8c5..95c005cc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectGetDepartmentPlanCountsQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectGetDepartmentPlanCountsQuery.cs @@ -16,7 +16,7 @@ public SelectGetDepartmentPlanCountsQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectGetDepartmentPlanCountsQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DepartmentCallPruningTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByIdQuery.cs index 18b5b8da..d8311e5c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByIdQuery.cs @@ -16,7 +16,7 @@ public SelectPaymentByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPaymentByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByTransactionIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByTransactionIdQuery.cs index 75eb569f..00f6a5ff 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByTransactionIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentByTransactionIdQuery.cs @@ -16,7 +16,7 @@ public SelectPaymentByTransactionIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPaymentByTransactionIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.PaymentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%TRANSACTIONID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentsByDIdQuery.cs index e3e8f72a..342b2345 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Payments/SelectPaymentsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectPaymentsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPaymentsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Permissions/SelectPermissionByDepartmentTypeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Permissions/SelectPermissionByDepartmentTypeQuery.cs index 42626d3b..c10d253c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Permissions/SelectPermissionByDepartmentTypeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Permissions/SelectPermissionByDepartmentTypeQuery.cs @@ -16,7 +16,7 @@ public SelectPermissionByDepartmentTypeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPermissionByDepartmentTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.PermissionsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%TYPE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleByDidAndNameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleByDidAndNameQuery.cs index 89abf4af..ad070f75 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleByDidAndNameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleByDidAndNameQuery.cs @@ -16,7 +16,7 @@ public SelectRoleByDidAndNameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRoleByDidAndNameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.PersonnelRolesTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%NAME%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByDidQuery.cs index f9bd2337..eed0fb7e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByDidQuery.cs @@ -16,11 +16,24 @@ public SelectRoleUsersByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRoleUsersByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.PersonnelRoleUsersTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { "%DID%" }, - new string[] { "DepartmentId" }); + new string[] { + "%DID%" + }, + new string[] { + "DepartmentId" + }, + new string[] { + "%PERSONNELROLEUSERSTABLE%", + "%PERSONNELROLESTABLE%" + }, + new string[] { + _sqlConfiguration.PersonnelRoleUsersTable, + _sqlConfiguration.PersonnelRolesTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByRoleQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByRoleQuery.cs index 79dccab9..a0d6b24f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByRoleQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByRoleQuery.cs @@ -16,11 +16,24 @@ public SelectRoleUsersByRoleQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRoleUsersByRoleQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.PersonnelRoleUsersTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { "%ROLEID%" }, - new string[] { "RoleId" }); + new string[] { + "%ROLEID%" + }, + new string[] { + "RoleId" + }, + new string[] { + "%PERSONNELROLEUSERSTABLE%", + "%DEPARTMENTMEMBERSTABLE%" + }, + new string[] { + _sqlConfiguration.PersonnelRoleUsersTable, + _sqlConfiguration.DepartmentMembersTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByUserQuery.cs index 260ee12c..bd2bda35 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRoleUsersByUserQuery.cs @@ -16,11 +16,26 @@ public SelectRoleUsersByUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRoleUsersByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.PersonnelRoleUsersTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { "%USERID%", "%DID%" }, - new string[] { "UserId", "DepartmentId" }); + new string[] { + "%USERID%", + "%DID%" + }, + new string[] { + "UserId", + "DepartmentId" + }, + new string[] { + "%PERSONNELROLEUSERSTABLE%", + "%PERSONNELROLESTABLE%" + }, + new string[] { + _sqlConfiguration.PersonnelRoleUsersTable, + _sqlConfiguration.PersonnelRolesTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidAndUserQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidAndUserQuery.cs index fa29f539..d793ca79 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidAndUserQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidAndUserQuery.cs @@ -16,11 +16,26 @@ public SelectRolesByDidAndUserQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRolesByDidAndUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.PersonnelRolesTable, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, _sqlConfiguration.ParameterNotation, - new string[] { "%USERID%", "%DID%" }, - new string[] { "UserId", "DepartmentId" }); + new string[] { + "%USERID%", + "%DID%" + }, + new string[] { + "UserId", + "DepartmentId" + }, + new string[] { + "%PERSONNELROLESTABLE%", + "%PERSONNELROLEUSERSTABLE%" + }, + new string[] { + _sqlConfiguration.PersonnelRolesTable, + _sqlConfiguration.PersonnelRoleUsersTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidQuery.cs index a8eee341..91cff716 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByDidQuery.cs @@ -16,7 +16,7 @@ public SelectRolesByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRolesByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByRoleIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByRoleIdQuery.cs index 49e5212a..4aaf13f6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByRoleIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/PersonnelRoles/SelectRolesByRoleIdQuery.cs @@ -16,7 +16,7 @@ public SelectRolesByRoleIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectRolesByRoleIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Plans/SelectPlanByPlanIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Plans/SelectPlanByPlanIdQuery.cs index 5e5a1ccf..2785b2f7 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Plans/SelectPlanByPlanIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Plans/SelectPlanByPlanIdQuery.cs @@ -16,7 +16,7 @@ public SelectPlanByPlanIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPlanByPlanIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolAttachmentsByProIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolAttachmentsByProIdQuery.cs index 9a9e9799..bf87ce5b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolAttachmentsByProIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolAttachmentsByProIdQuery.cs @@ -16,7 +16,7 @@ public SelectProtocolAttachmentsByProIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProtocolAttachmentsByProIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.DispatchProtocolAttachmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%PROTOCOLID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolByIdQuery.cs index 153bb884..df76dace 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolByIdQuery.cs @@ -16,7 +16,7 @@ public SelectProtocolByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProtocolByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolQuestionsByProIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolQuestionsByProIdQuery.cs index fea1369e..f2649c40 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolQuestionsByProIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolQuestionsByProIdQuery.cs @@ -16,7 +16,7 @@ public SelectProtocolQuestionsByProIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProtocolQuestionsByProIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolTriggersByProIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolTriggersByProIdQuery.cs index 20b140fa..aa5d3035 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolTriggersByProIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolTriggersByProIdQuery.cs @@ -16,7 +16,7 @@ public SelectProtocolTriggersByProIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProtocolTriggersByProIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolsByDIdQuery.cs index 6387750d..73ba909f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Protocols/SelectProtocolsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectProtocolsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProtocolsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Queues/SelectQueueItemByTypeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Queues/SelectQueueItemByTypeQuery.cs index a8f92742..65eecb5b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Queues/SelectQueueItemByTypeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Queues/SelectQueueItemByTypeQuery.cs @@ -16,7 +16,7 @@ public SelectQueueItemByTypeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectQueueItemByTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.QueueItemsTable, _sqlConfiguration.ParameterNotation, new string[] { "%TYPE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllItemsByOrderIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllItemsByOrderIdQuery.cs index 57b01007..b4e8d5bd 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllItemsByOrderIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllItemsByOrderIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllItemsByOrderIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllItemsByOrderIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ResourceOrderItemsTable, _sqlConfiguration.ParameterNotation, new string[] { "%ID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenNonDVisibleOrdersQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenNonDVisibleOrdersQuery.cs index 8cf2435b..f4ef8f6e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenNonDVisibleOrdersQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenNonDVisibleOrdersQuery.cs @@ -16,7 +16,7 @@ public SelectAllOpenNonDVisibleOrdersQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllOpenNonDVisibleOrdersQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ResourceOrdersTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%DATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenOrdersQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenOrdersQuery.cs index ffc5375f..cf1bd0b4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenOrdersQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectAllOpenOrdersQuery.cs @@ -16,7 +16,7 @@ public SelectAllOpenOrdersQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllOpenOrdersQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ResourceOrdersTable, _sqlConfiguration.ParameterNotation, new string[] { }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectItemsByResourceOrderIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectItemsByResourceOrderIdQuery.cs index bfcaee79..a63b1aea 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectItemsByResourceOrderIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectItemsByResourceOrderIdQuery.cs @@ -16,7 +16,7 @@ public SelectItemsByResourceOrderIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectItemsByResourceOrderIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderByIdQuery.cs index ff6196b4..5d8f2760 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderByIdQuery.cs @@ -16,7 +16,7 @@ public SelectOrderByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectMessagesByUserQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderFillUnitsByFillIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderFillUnitsByFillIdQuery.cs index bf8f5c35..fdb96a98 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderFillUnitsByFillIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/SelectOrderFillUnitsByFillIdQuery.cs @@ -16,7 +16,7 @@ public SelectOrderFillUnitsByFillIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectOrderFillUnitsByFillIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/UpdateOrderFillStatusQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/UpdateOrderFillStatusQuery.cs index 43a47d75..9833b1bf 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/UpdateOrderFillStatusQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ResourceOrders/UpdateOrderFillStatusQuery.cs @@ -19,7 +19,7 @@ public string GetQuery(TEntity entity) var setFragment = updateValues.UpdateQuerySetFragment(_sqlConfiguration.ParameterNotation); var query = _sqlConfiguration.UpdateRoleQuery - .ReplaceUpdateQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceUpdateQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.RoleTable, setFragment, "ResourceOrderFillId", diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/ScheduledTasks/SelectAllUpcomingOrRecurringReportTasksQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/ScheduledTasks/SelectAllUpcomingOrRecurringReportTasksQuery.cs index 82948c1e..eba31ec8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/ScheduledTasks/SelectAllUpcomingOrRecurringReportTasksQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/ScheduledTasks/SelectAllUpcomingOrRecurringReportTasksQuery.cs @@ -16,7 +16,7 @@ public SelectAllUpcomingOrRecurringReportTasksQuery(SqlConfiguration sqlConfigur public string GetQuery() { var query = _sqlConfiguration.SelectAllUpcomingOrRecurringReportTasksQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectOpenShiftSignupTradesByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectOpenShiftSignupTradesByUserIdQuery.cs index 08dc0459..f944ea64 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectOpenShiftSignupTradesByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectOpenShiftSignupTradesByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectOpenShiftSignupTradesByUserIdQuery(SqlConfiguration sqlConfiguratio public string GetQuery() { var query = _sqlConfiguration.SelectOpenShiftSignupTradesByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitStatesTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByDIdQuery.cs index 6d7eea4a..05a68225 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftAndDaysByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftsByDidJSONQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByShiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByShiftIdQuery.cs index f411eb06..da8a8352 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByShiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysByShiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftAndDaysByShiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftByShiftIdJSONQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysQuery.cs index 75821eec..57bdfaff 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAndDaysQuery.cs @@ -16,7 +16,7 @@ public SelectShiftAndDaysQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftAndDaysJSONQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAssignmentByGroupQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAssignmentByGroupQuery.cs index 85f43f23..1e57a52a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAssignmentByGroupQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftAssignmentByGroupQuery.cs @@ -16,7 +16,7 @@ public SelectShiftAssignmentByGroupQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftAssignmentByGroupQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftGroupAssignmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%SHIFTGROUPID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftByShiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftByShiftIdQuery.cs index 0e4cbf2a..b804718a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftByShiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftByShiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftByShiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftByShiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDayByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDayByIdQuery.cs index a23d6e6a..b276baf3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDayByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDayByIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftDayByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftDayByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDaysByShiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDaysByShiftIdQuery.cs index 533f43ed..2cebbc16 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDaysByShiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftDaysByShiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftDaysByShiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftDaysByShiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftDaysTable, _sqlConfiguration.ParameterNotation, new string[] { "%SHIFTID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByGroupQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByGroupQuery.cs index 23879840..c6b1ed62 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByGroupQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByGroupQuery.cs @@ -16,7 +16,7 @@ public SelectShiftGroupByGroupQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftGroupByGroupQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByShiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByShiftIdQuery.cs index b84f6bbe..fce296f8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByShiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupByShiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftGroupByShiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftGroupByShiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupRolesByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupRolesByGroupIdQuery.cs index b81ea82d..26791cfa 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupRolesByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftGroupRolesByGroupIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftGroupRolesByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftGroupRolesByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftPersonByShiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftPersonByShiftIdQuery.cs index 1a51f1ba..879381dd 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftPersonByShiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftPersonByShiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftPersonByShiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftPersonByShiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftPersonsTable, _sqlConfiguration.ParameterNotation, new string[] { "%SHIFTID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdDateQuery.cs index 5f9e558d..b6fb403c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdDateQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupByShiftIdDateQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupByShiftIdDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftSignupsTable, _sqlConfiguration.ParameterNotation, new string[] { "%SHIFTID%", "%SHIFTDAYDATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdQuery.cs index 5fb058a3..68cafe8b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByShiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupByShiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupByShiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftSignupsTable, _sqlConfiguration.ParameterNotation, new string[] { "%SHIFTID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByUserIdQuery.cs index 9e665722..fb3511d8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftSignupsTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeBySourceIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeBySourceIdQuery.cs index 6b1208b2..b7976677 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeBySourceIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeBySourceIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupTradeBySourceIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupTradeBySourceIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByTargetIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByTargetIdQuery.cs index 9096c3ee..bebd763b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByTargetIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByTargetIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupTradeByTargetIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupTradeByTargetIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByUserIdQuery.cs index b308b76d..7d558b5c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupTradeByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupTradeByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeUsersByTradeIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeUsersByTradeIdQuery.cs index 0450864b..4c3e70d0 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeUsersByTradeIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupTradeUsersByTradeIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupTradeUsersByTradeIdQuery(SqlConfiguration sqlConfigurati public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupTradeUsersByTradeIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupsByGroupIdAndDateQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupsByGroupIdAndDateQuery.cs index 9b12b3d5..2b977651 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupsByGroupIdAndDateQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftSignupsByGroupIdAndDateQuery.cs @@ -16,7 +16,7 @@ public SelectShiftSignupsByGroupIdAndDateQuery(SqlConfiguration sqlConfiguration public string GetQuery() { var query = _sqlConfiguration.SelectShiftSignupsByGroupIdAndDateQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.ShiftSignupsTable, _sqlConfiguration.ParameterNotation, new string[] { "%GROUPID%", "%SHIFTDAYDATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftStaffingByDayQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftStaffingByDayQuery.cs index f20ad151..6c524d90 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftStaffingByDayQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftStaffingByDayQuery.cs @@ -16,7 +16,7 @@ public SelectShiftStaffingByDayQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftStaffingByDayQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftTradeAndSourceByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftTradeAndSourceByUserIdQuery.cs index e3de7a28..f47d5030 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftTradeAndSourceByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Shifts/SelectShiftTradeAndSourceByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectShiftTradeAndSourceByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectShiftTradeAndSourceByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingAttachmentsBytIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingAttachmentsBytIdQuery.cs index 136a9889..5ba58743 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingAttachmentsBytIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingAttachmentsBytIdQuery.cs @@ -16,7 +16,7 @@ public SelectTrainingAttachmentsBytIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectTrainingAttachmentsBytIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.TrainingAttachmentsTable, _sqlConfiguration.ParameterNotation, new string[] { "%TRAININGID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingByIdQuery.cs index 059fe93c..e3a83ed1 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingByIdQuery.cs @@ -16,7 +16,7 @@ public SelectTrainingByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectTrainingByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingQuestionsByTrainIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingQuestionsByTrainIdQuery.cs index 7ac2cfd2..2ae73bb1 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingQuestionsByTrainIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingQuestionsByTrainIdQuery.cs @@ -16,7 +16,7 @@ public SelectTrainingQuestionsByTrainIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectTrainingQuestionsByTrainIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingUserByTandUIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingUserByTandUIdQuery.cs index 3b5923a1..0355fd0f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingUserByTandUIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingUserByTandUIdQuery.cs @@ -16,7 +16,7 @@ public SelectTrainingUserByTandUIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectTrainingUserByTandUIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.TrainingUsersTable, _sqlConfiguration.ParameterNotation, new string[] { "%TRAININGID%", "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingsByDIdQuery.cs index 45da34a2..42f367c6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Trainings/SelectTrainingsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectTrainingsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectTrainingsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UnitStates/SelectUnitStatesByUnitInDateRangeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UnitStates/SelectUnitStatesByUnitInDateRangeQuery.cs index 14a1d088..a7126806 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UnitStates/SelectUnitStatesByUnitInDateRangeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UnitStates/SelectUnitStatesByUnitInDateRangeQuery.cs @@ -16,7 +16,7 @@ public SelectUnitStatesByUnitInDateRangeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitStatesByUnitInDateRangeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/DeleteUnitActiveRolesByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/DeleteUnitActiveRolesByUnitIdQuery.cs index 9e9b7fae..1980dc74 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/DeleteUnitActiveRolesByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/DeleteUnitActiveRolesByUnitIdQuery.cs @@ -17,7 +17,7 @@ public DeleteUnitActiveRolesByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.DeleteUnitActiveRolesByUnitIdQuery - .ReplaceDeleteQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceDeleteQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitActiveRolesTable, "UnitId", "%UNITID%"); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectActiveRolesForUnitsByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectActiveRolesForUnitsByDidQuery.cs index 4a0d51eb..39f849d8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectActiveRolesForUnitsByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectActiveRolesForUnitsByDidQuery.cs @@ -16,7 +16,7 @@ public SelectActiveRolesForUnitsByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectActiveRolesForUnitsByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitActiveRolesTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectCurrentRolesByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectCurrentRolesByUnitIdQuery.cs index 07aba46d..80fcd30f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectCurrentRolesByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectCurrentRolesByUnitIdQuery.cs @@ -16,7 +16,7 @@ public SelectCurrentRolesByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectCurrentRolesByUnitIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdQuery.cs index cbd9f8db..33bf5e83 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdQuery.cs @@ -16,7 +16,7 @@ public SelectLastUnitStateByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastUnitStateByUnitIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdTimeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdTimeQuery.cs index 6dcb3707..d56a303d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdTimeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStateByUnitIdTimeQuery.cs @@ -16,7 +16,7 @@ public SelectLastUnitStateByUnitIdTimeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastUnitStateByUnitIdTimeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStatesByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStatesByDidQuery.cs index 9d4be84b..57a4f3d0 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStatesByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLastUnitStatesByDidQuery.cs @@ -16,7 +16,7 @@ public SelectLastUnitStatesByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastUnitStatesByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitId.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitId.cs index 2b25e566..226592f4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitId.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitId.cs @@ -16,7 +16,7 @@ public SelectLatestUnitLocationByUnitId(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLatestUnitLocationByUnitId - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitLocationsTable, _sqlConfiguration.ParameterNotation, new string[] { "%UNITID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitIdTimeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitIdTimeQuery.cs index 6c396d5d..38de0d86 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitIdTimeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectLatestUnitLocationByUnitIdTimeQuery.cs @@ -16,7 +16,7 @@ public SelectLatestUnitLocationByUnitIdTimeQuery(SqlConfiguration sqlConfigurati public string GetQuery() { var query = _sqlConfiguration.SelectLatestUnitLocationByUnitIdTimeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitLocationsTable, _sqlConfiguration.ParameterNotation, new string[] { "%UNITID%", "%TIMESTAMP%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitActiveRolesByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitActiveRolesByUnitIdQuery.cs index 9e650cea..cb7c1270 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitActiveRolesByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitActiveRolesByUnitIdQuery.cs @@ -16,7 +16,7 @@ public SelectUnitActiveRolesByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitActiveRolesByUnitIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitActiveRolesTable, _sqlConfiguration.ParameterNotation, new string[] { "%UNITID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdNameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdNameQuery.cs index 66bba654..b5da92af 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdNameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdNameQuery.cs @@ -16,7 +16,7 @@ public SelectUnitByDIdNameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitByDIdNameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitsTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%UNITNAME%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdTypeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdTypeQuery.cs index a983f996..8ea5782f 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdTypeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitByDIdTypeQuery.cs @@ -16,7 +16,7 @@ public SelectUnitByDIdTypeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitByDIdTypeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.TrainingUsersTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%TYPE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitLogsByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitLogsByUnitIdQuery.cs index d9fd511a..a0992bc7 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitLogsByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitLogsByUnitIdQuery.cs @@ -16,7 +16,7 @@ public SelectUnitLogsByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitLogsByUnitIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitLogsTable, _sqlConfiguration.ParameterNotation, new string[] { "%UNITID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitRolesByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitRolesByUnitIdQuery.cs index 48162c38..8607a567 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitRolesByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitRolesByUnitIdQuery.cs @@ -16,7 +16,7 @@ public SelectUnitRolesByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitRolesByUnitIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitRolesTable, _sqlConfiguration.ParameterNotation, new string[] { "%UNITID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStateByUnitStateIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStateByUnitStateIdQuery.cs index 2f08c5b9..efd57732 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStateByUnitStateIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStateByUnitStateIdQuery.cs @@ -16,7 +16,7 @@ public SelectUnitStateByUnitStateIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitStateByUnitStateIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByCallIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByCallIdQuery.cs index a4de379d..00fa21bb 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByCallIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByCallIdQuery.cs @@ -16,7 +16,7 @@ public SelectUnitStatesByCallIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitStatesByCallIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByUnitIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByUnitIdQuery.cs index db869e62..86e1c772 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByUnitIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitStatesByUnitIdQuery.cs @@ -16,7 +16,7 @@ public SelectUnitStatesByUnitIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitStatesByUnitIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitTypeByDIdNameQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitTypeByDIdNameQuery.cs index 27009c0c..88b0c093 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitTypeByDIdNameQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitTypeByDIdNameQuery.cs @@ -16,7 +16,7 @@ public SelectUnitTypeByDIdNameQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitTypeByDIdNameQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UnitTypesTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%TYPENAME%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByDIdQuery.cs index 946052db..7cf21311 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByDIdQuery.cs @@ -16,11 +16,24 @@ public SelectUnitsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.UnitsTable, - _sqlConfiguration.ParameterNotation, - new string[] { "%DID%" }, - new string[] { "DepartmentId" }); + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, + _sqlConfiguration.ParameterNotation, + new string[] { + "%DID%" + }, + new string[] { + "DepartmentId", + }, + new string[] { + "%UNITSTABLE%", + "%UNITROLESTABLE%" + }, + new string[] { + _sqlConfiguration.UnitsTable, + _sqlConfiguration.UnitRolesTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByGroupIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByGroupIdQuery.cs index 4fe59500..00d929e0 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByGroupIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Units/SelectUnitsByGroupIdQuery.cs @@ -16,11 +16,24 @@ public SelectUnitsByGroupIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUnitsByGroupIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, - _sqlConfiguration.UnitsTable, - _sqlConfiguration.ParameterNotation, - new string[] { "%GROUPID%" }, - new string[] { "GroupId" }); + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, + string.Empty, + _sqlConfiguration.ParameterNotation, + new string[] { + "%GROUPID%" + }, + new string[] { + "GroupId", + }, + new string[] { + "%UNITSTABLE%", + "%DEPARTMENTGROUPSTABLE%" + }, + new string[] { + _sqlConfiguration.UnitsTable, + _sqlConfiguration.DepartmentGroupsTable + } + ); return query; } diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllNonDeletedProfilesByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllNonDeletedProfilesByDIdQuery.cs index 6e39c755..ea598e9b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllNonDeletedProfilesByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllNonDeletedProfilesByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllNonDeletedProfilesByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllNonDeletedProfilesByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllProfilesByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllProfilesByDIdQuery.cs index 154ec9cd..c02e9f05 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllProfilesByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectAllProfilesByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectAllProfilesByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllProfilesByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByHomeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByHomeQuery.cs index c0d88aed..35f2c3c2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByHomeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByHomeQuery.cs @@ -16,7 +16,7 @@ public SelectProfileByHomeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProfileByHomeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByMobileQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByMobileQuery.cs index 256511a9..475afc0d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByMobileQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByMobileQuery.cs @@ -16,7 +16,7 @@ public SelectProfileByMobileQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProfileByMobileQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByUserIdQuery.cs index 4eaa7ab0..31e1edd5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfileByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectProfileByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProfileByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfilesByIdsQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfilesByIdsQuery.cs index cf8d702c..a0a32ed4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfilesByIdsQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserProfiles/SelectProfilesByIdsQuery.cs @@ -16,7 +16,7 @@ public SelectProfilesByIdsQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectProfilesByIdsQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLastUserStatesByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLastUserStatesByUserIdQuery.cs index d0e6300a..f7691341 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLastUserStatesByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLastUserStatesByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectLastUserStatesByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLastUserStatesByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserStatesTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLatestUserStatesByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLatestUserStatesByDidQuery.cs index bc15e491..8f85e30e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLatestUserStatesByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectLatestUserStatesByDidQuery.cs @@ -16,7 +16,7 @@ public SelectLatestUserStatesByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectLatestUserStatesByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserStatesTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%TIMESTAMP%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectPreviousUserStatesByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectPreviousUserStatesByUserIdQuery.cs index 428b0dd5..c4d0b381 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectPreviousUserStatesByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectPreviousUserStatesByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectPreviousUserStatesByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectPreviousUserStatesByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserStatesTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%", "%USERSTATEID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByDIdDateRangeQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByDIdDateRangeQuery.cs index eba56ff2..2f1081df 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByDIdDateRangeQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByDIdDateRangeQuery.cs @@ -16,7 +16,7 @@ public SelectUserStatesByDIdDateRangeQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUserStatesByDIdDateRangeQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserStatesTable, _sqlConfiguration.ParameterNotation, new string[] { "%DID%", "%STARTDATE%", "%ENDDATE%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByUserIdQuery.cs index 5e09081f..025ad659 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/UserStates/SelectUserStatesByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectUserStatesByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectUserStatesByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, _sqlConfiguration.UserStatesTable, _sqlConfiguration.ParameterNotation, new string[] { "%USERID%" }, diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceByDIdQuery.cs index ba730fa4..13460e3d 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectVoiceByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectVoiceByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByDIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByDIdQuery.cs index 4cc0c01a..a91d7901 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByDIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByDIdQuery.cs @@ -16,7 +16,7 @@ public SelectVoiceChannelsByDIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectVoiceChannelsByDIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByVoiceIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByVoiceIdQuery.cs index 0d15c3bf..7d66c31c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByVoiceIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceChannelsByVoiceIdQuery.cs @@ -16,7 +16,7 @@ public SelectVoiceChannelsByVoiceIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectVoiceChannelsByVoiceIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceUserByUserIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceUserByUserIdQuery.cs index 5bd056d8..032447dc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceUserByUserIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Voice/SelectVoiceUserByUserIdQuery.cs @@ -16,7 +16,7 @@ public SelectVoiceUserByUserIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectVoiceUserByUserIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectAllWorkshiftsAndDaysByDidQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectAllWorkshiftsAndDaysByDidQuery.cs index 6e96abd6..aa13859c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectAllWorkshiftsAndDaysByDidQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectAllWorkshiftsAndDaysByDidQuery.cs @@ -16,7 +16,7 @@ public SelectAllWorkshiftsAndDaysByDidQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectAllWorkshiftsAndDaysByDidQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftByIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftByIdQuery.cs index 8a70a1e8..d402bc35 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftByIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftByIdQuery.cs @@ -16,7 +16,7 @@ public SelectWorkshiftByIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectWorkshiftByIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftEntitiesByWorkshiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftEntitiesByWorkshiftIdQuery.cs index c6fdf24b..c084890e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftEntitiesByWorkshiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftEntitiesByWorkshiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectWorkshiftEntitiesByWorkshiftIdQuery(SqlConfiguration sqlConfigurati public string GetQuery() { var query = _sqlConfiguration.SelectWorkshiftEntitiesByWorkshiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftFillsByWorkshiftIdQuery.cs b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftFillsByWorkshiftIdQuery.cs index b50a4c71..76de4a54 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftFillsByWorkshiftIdQuery.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Queries/Workshifts/SelectWorkshiftFillsByWorkshiftIdQuery.cs @@ -16,7 +16,7 @@ public SelectWorkshiftFillsByWorkshiftIdQuery(SqlConfiguration sqlConfiguration) public string GetQuery() { var query = _sqlConfiguration.SelectWorkshiftFillsByWorkshiftIdQuery - .ReplaceQueryParameters(_sqlConfiguration.SchemaName, + .ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName, string.Empty, _sqlConfiguration.ParameterNotation, new string[] { diff --git a/Repositories/Resgrid.Repositories.DataRepository/QueueItemsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/QueueItemsRepository.cs index 463b233c..9ebdb1d7 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/QueueItemsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/QueueItemsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetPendingQueueItemsByTypeIdAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Type", typeId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/RepositoryBase.cs b/Repositories/Resgrid.Repositories.DataRepository/RepositoryBase.cs index 8dd5dbe9..9825174c 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/RepositoryBase.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/RepositoryBase.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Dapper; +using Resgrid.Config; using Resgrid.Framework; using Resgrid.Model; using Resgrid.Model.Repositories; @@ -38,7 +39,7 @@ public virtual async Task> GetAllAsync() { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); var query = _queryFactory.GetQuery(); @@ -77,8 +78,12 @@ public virtual async Task GetByIdAsync(object id) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); - dynamicParameters.Add("Id", id); + var dynamicParameters = new DynamicParametersExtension(); + + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + dynamicParameters.Add("id", id); + else + dynamicParameters.Add("Id", id); var query = _queryFactory.GetQuery(); @@ -117,8 +122,12 @@ public virtual async Task> GetAllByDepartmentIdAsync(int departme { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); - dynamicParameters.Add("DepartmentId", departmentId); + var dynamicParameters = new DynamicParametersExtension(); + + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + dynamicParameters.Add("departmentid", departmentId); + else + dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -255,7 +264,7 @@ public virtual async Task DeleteAsync(T entity, CancellationToken cancella { var removeFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Id", ((IEntity)entity).IdValue); var query = _queryFactory.GetDeleteQuery(entity); @@ -316,7 +325,7 @@ public virtual async Task> GetAllByUserIdAsync(string userId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -356,13 +365,13 @@ public virtual async Task DeleteMultipleAsync(T entity, string parentKeyNa { var removeFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); var usersToQuery = String.Join(",", ids.Select(p => $"{p.ToString()}").ToArray()); dynamicParameters.Add("ParentId", parentKeyId); var query = _queryFactory.GetDeleteQuery(entity); - query = query.Replace("%IDS%", usersToQuery); - query = query.Replace("%PARENTKEYNAME%", parentKeyName); + query = query.Replace("%IDS%", usersToQuery, StringComparison.InvariantCultureIgnoreCase); + query = query.Replace("%PARENTKEYNAME%", parentKeyName, StringComparison.InvariantCultureIgnoreCase); var result = await x.ExecuteAsync(query, dynamicParameters, _unitOfWork.Transaction); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj b/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj index c1398b86..ae338af3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj +++ b/Repositories/Resgrid.Repositories.DataRepository/Resgrid.Repositories.DataRepository.csproj @@ -8,13 +8,17 @@ + + + + \ No newline at end of file diff --git a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillRepository.cs index 2fc2d138..53eb8d14 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillRepository.cs @@ -35,7 +35,7 @@ public async Task UpdateFillStatusAsync(int fillId, string userId, bool ac { var updateFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("Accepted", accepted); dynamicParameters.Add("AcceptedUserId", userId); dynamicParameters.Add("AcceptedOn", DateTime.UtcNow); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillUnitRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillUnitRepository.cs index facd590d..c974a7c6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillUnitRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderFillUnitRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllResourceOrderFillUni { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ResourceOrderFillId", resourceOrderFillId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderItemRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderItemRepository.cs index 0faddafd..24cdae75 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderItemRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrderItemRepository.cs @@ -38,7 +38,7 @@ public async Task> GetAllItemsByResourceItemIdAsy var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ResourceOrderId", resourceOrderId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrdersRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrdersRepository.cs index e9c4aefb..26431160 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ResourceOrdersRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ResourceOrdersRepository.cs @@ -45,7 +45,7 @@ public async Task> GetAllOpenOrdersAsync() var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); var query = _queryFactory.GetQuery(); @@ -88,7 +88,7 @@ public async Task> GetAllNonDepartmentOpenVisibleOrde var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("CurrentDate", DateTime.UtcNow.AddDays(-7)); @@ -213,7 +213,7 @@ public async Task> GetAllItemsByResourceOrderIdAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ResourceOrderId", resourceOrderId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs index 4ae4b9b3..51d4ecd5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ScheduledTasksRepository.cs @@ -16,6 +16,7 @@ using Resgrid.Repositories.DataRepository.Configs; using Resgrid.Repositories.DataRepository.Queries.ResourceOrders; using Resgrid.Repositories.DataRepository.Queries.ScheduledTasks; +using Resgrid.Config; namespace Resgrid.Repositories.DataRepository { @@ -70,8 +71,11 @@ public async Task> GetAllUpcomingOrRecurringReportDel { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); - dynamicParameters.Add("DateTime", DateTime.UtcNow.ToString()); + var dynamicParameters = new DynamicParametersExtension(); + if (DataConfig.DatabaseType == DatabaseTypes.Postgres) + dynamicParameters.Add("DateTime", DateTime.UtcNow); + else + dynamicParameters.Add("DateTime", DateTime.UtcNow.ToString()); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConfiguration.cs b/Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConfiguration.cs new file mode 100644 index 00000000..0016a8eb --- /dev/null +++ b/Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConfiguration.cs @@ -0,0 +1,1386 @@ +using Resgrid.Config; +using Resgrid.Repositories.DataRepository.Configs; +using Resgrid.Repositories.DataRepository.Queries.Calendar; +using Resgrid.Repositories.DataRepository.Queries.Calls; +using Resgrid.Repositories.DataRepository.Queries.DepartmentGroups; +using Resgrid.Repositories.DataRepository.Queries.Departments; +using Resgrid.Repositories.DataRepository.Queries.Logs; +using Resgrid.Repositories.DataRepository.Queries.Mapping; +using Resgrid.Repositories.DataRepository.Queries.Notes; +using Resgrid.Repositories.DataRepository.Queries.Plans; +using Resgrid.Repositories.DataRepository.Queries.Shifts; +using Resgrid.Repositories.DataRepository.Queries.Trainings; +using Resgrid.Repositories.DataRepository.Queries.Units; +using Resgrid.Repositories.DataRepository.Queries.UserProfiles; +using Resgrid.Repositories.DataRepository.Queries.UserStates; + +namespace Resgrid.Repositories.DataRepository.Servers.SqlServer +{ + public class PostgreSqlConfiguration : SqlConfiguration + { + public PostgreSqlConfiguration() + { + ParameterNotation = "@"; + SchemaName = "public"; + TableColumnStartNotation = "\""; + TableColumnEndNotation = "\""; + InsertGetReturnIdCommand = + "; SELECT lastval();"; // For Postgresql INSERT INTO persons (lastname,firstname) VALUES ('Smith', 'John') RETURNING id; https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id/2944481 + QueryPrefix = DataConfig.QueryPrefix; + #region Common Queries + + InsertQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%)%RETURNID%"; + DeleteQuery = "DELETE FROM %SCHEMA%.%TABLENAME% WHERE %IDCOLUMN% = %ID%"; + DeleteMultipleQuery = + "DELETE FROM %SCHEMA%.%BASETABLENAME% WHERE %PARENTKEYNAME% = %PARENTID% AND %IDCOLUMN% NOT IN (%IDS%)"; + UpdateQuery = "UPDATE %SCHEMA%.%TABLENAME% %SETVALUES% WHERE %IDCOLUMN% = %ID%"; + SelectByIdQuery = "SELECT * FROM %SCHEMA%.%BASETABLENAME% WHERE %IDCOLUMN% = %ID%"; + SelectAllQuery = "SELECT * FROM %SCHEMA%.%TABLENAME%"; + SelectByDepartmentIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID%"; + SelectByUserIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %ID%"; + + #endregion Common Queries + + #region Action Logs + + ActionLogsTable = "ActionLogs"; + SelectLastActionLogsForDepartmentQuery = @" + SELECT al.*, u.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% al + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = al.UserId + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.UserId = al.UserId + WHERE al.DepartmentId = %DID% AND dm.IsDeleted = false AND + (%DAA% = true OR al.Timestamp >= %TS%) AND + dm.IsDisabled = false AND dm.IsHidden = false AND al.Timestamp >= %LTS%"; + SelectActionLogsByUserIdQuery = @" + SELECT %SCHEMA%.%ACTIONLOGSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%ACTIONLOGSTABLE%.UserId + UserId = %ID%"; + SelectALogsByUserInDateRangQuery = @" + SELECT %SCHEMA%.%ACTIONLOGSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%ACTIONLOGSTABLE%.UserId + WHERE UserId = %USERID% AND Timestamp >= %STARTDATE% AND Timestamp <= %ENDDATE%"; + SelectALogsByDateRangeQuery = @" + SELECT %SCHEMA%.%ACTIONLOGSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%ACTIONLOGSTABLE%.UserId + WHERE DepartmentId = %DID% AND Timestamp >= %STARTDATE% AND Timestamp <= %ENDDATE%"; + SelectALogsByDidQuery = @" + SELECT al.*, u.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% al + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = al.UserId + WHERE al.DepartmentId = %DID%"; + SelectLastActionLogForUserQuery = @" + SELECT al.*, u.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% al + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = al.UserId + WHERE al.UserId = %USERID% AND (%DAA% = true OR al.Timestamp >= %TS%) + ORDER BY ActionLogId DESC limit 1"; + SelectActionLogsByCallIdTypeQuery = @" + SELECT al.*, u.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% al + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = al.UserId + WHERE al.DestinationId = %CALLID% AND (al.ActionTypeId IS NULL OR al.ActionTypeId IN (%TYPES%))"; + SelectPreviousActionLogsByUserQuery = @" + SELECT %SCHEMA%.%ACTIONLOGSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% a1 + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%ACTIONLOGSTABLE%.UserId + WHERE a1.UserId = %USERID% AND ActionLogId < %ACTIONLOGID%"; + SelectLastActionLogByUserIdQuery = @" + SELECT %SCHEMA%.%ACTIONLOGSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% a1 + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%ACTIONLOGSTABLE%.UserId + WHERE a1.UserId = %USERID% + ORDER BY ActionLogId DESC limit 1"; + SelectActionLogsByCallIdQuery = @" + SELECT al.*, u.* + FROM %SCHEMA%.%ACTIONLOGSTABLE% al + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = al.UserId + WHERE al.DestinationId = %DID%"; + + #endregion ActionLogs + + #region Department Members + + DepartmentMembersTable = "DepartmentMembers"; + DepartmentCallPruningTable = "DepartmentCallPruning"; + + SelectMembersUnlimitedQuery = @" + SELECT %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId + WHERE DepartmentId = %ID% AND IsDeleted = false"; + + SelectMembersUnlimitedInclDelQuery = @" + SELECT %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId + WHERE DepartmentId = %ID%"; + + //SelectMembersWithinLimitsQuery = @"DECLARE @limit INT + // SET @limit = (SELECT TOP 1 (pl.LimitValue * p.Quantity) FROM Payments p + // INNER JOIN PlanLimits pl ON pl.PlanId = p.PlanId + // WHERE DepartmentId = %ID% AND pl.LimitType = true AND p.EffectiveOn <= GETUTCDATE() AND p.EndingOn >= GETUTCDATE() + // ORDER BY PaymentId DESC) + + + // SELECT TOP (@limit) %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as 'MembershipEmail', %SCHEMA%.%ASPNETUSERSTABLE%.* + // FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% + // INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId + // WHERE DepartmentId = %ID% AND IsDeleted = false"; + + SelectMembersWithinLimitsQuery = @" + SELECT %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId + WHERE DepartmentId = %ID% AND IsDeleted = false"; + + + SelectMembersByDidUserIdQuery = @" + SELECT %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId + WHERE UserId = %USERID% AND DepartmentId = %DID%"; + + SelectMembersByUserIdQuery = @" + SELECT dm.*, d.* + FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm + INNER JOIN %SCHEMA%.%DEPARTMENTSTABLE% d ON d.DepartmentId = dm.DepartmentId + WHERE dm.UserId = %USERID%"; + + #endregion Department Members + + #region Department Settings + + DepartmentSettingsTable = "DepartmentSettings"; + SelectDepartmentSettingByDepartmentIdTypeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND SettingType = %SETTINGTYPE%"; + SelectDepartmentSettingByTypeUserIdQuery = @"SELECT ds.* FROM %SCHEMA%.%DEPARTMENTSETTINGSTABLE% ds + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON ds.DepartmentId = dm.DepartmentId + WHERE dm.UserId = %USERID% AND ds.SettingType = %SETTINGTYPE%"; + SelectDepartmentSettingBySettingAndTypeQuery = @"SELECT ds.* FROM %SCHEMA%.%TABLENAME% ds + WHERE ds.Setting = %SETTING% AND ds.SettingType = %SETTINGTYPE%"; + SelectAllDepartmentManagerInfoQuery = @"SELECT d.DepartmentId, d.Name, up.FirstName, up.LastName, u.Email + FROM %SCHEMA%.%DEPARTMENTSTABLE% d + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = d.ManagingUserId + LEFT OUTER JOIN UserProfiles up ON up.UserId = d.ManagingUserId"; + SelectDepartmentManagerInfoByEmailQuery = + @"SELECT d.DepartmentId, d.Name, up.FirstName, up.LastName, u.Email + FROM %SCHEMA%.%DEPARTMENTSTABLE% d + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = d.ManagingUserId + LEFT OUTER JOIN %SCHEMA%.%USERPROFILESTABLE% up ON up.UserId = d.ManagingUserId + WHERE u.Email = %EMAILADDRESS%"; + + #endregion Department Settings + + #region Invites + + InvitesTable = "Invites"; + SelectInviteByCodeQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE Code = %CODE%"; + SelectInviteByEmailQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE EmailAddress = %EMAIL%"; + + #endregion Invites + + #region Queues + + QueueItemsTable = "QueueItems"; + SelectQueueItemByTypeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE QueueType = %TYPE% AND PickedUp IS NULL && CompletedOn IS NULL"; + + #endregion Queues + + #region Certifications + + CertificationsTable = "PersonnelCertifications"; + + SelectCertsByUserQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID%"; + + #endregion Certifications + + #region Permissions + + PermissionsTable = "Permissions"; + + SelectPermissionByDepartmentTypeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND PermissionType = %TYPE%"; + + #endregion Permissions + + #region Department Links + + DepartmentLinksTable = "DepartmentLinks"; + + SelectAllLinksForDepartmentQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% OR LinkedDepartmentId = %DID%"; + SelectAllLinkForDepartmentIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% OR DepartmentLinkId = %ID%"; + + #endregion Department Links + + #region Departments + + DepartmentsTable = "Departments"; + SelectDepartmentByLinkCodeQuery = @" + SELECT %SCHEMA%.%DEPARTMENTSTABLE%.*, %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.* + FROM %SCHEMA%.%DEPARTMENTSTABLE% + LEFT JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% ON %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.DepartmentId = %SCHEMA%.%DEPARTMENTSTABLE%.DepartmentId + WHERE LinkCode = %CODE%"; + SelectDepartmentByIdQuery = @" + SELECT d.*, dt.* + FROM %SCHEMA%.%DEPARTMENTSTABLE% d + LEFT JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dt ON dt.DepartmentId = d.DepartmentId + WHERE d.DepartmentId = %DID%"; + SelectCallPruningByDidQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID%"; + SelectDepartmentReportByDidQuery = @"SELECT + d.DepartmentId, + d.Name, + d.CreatedOn, + (SELECT COUNT (*) FROM DepartmentGroups dg WHERE dg.DepartmentId = d.DepartmentId) AS 'Groups', + (SELECT COUNT (*) -1 FROM DepartmentMembers dm WHERE dm.DepartmentId = d.DepartmentId) AS 'Users', + (SELECT COUNT (*) FROM Units u WHERE u.DepartmentId = d.DepartmentId) AS 'Units', + (SELECT COUNT (*) FROM Calls c WHERE c.DepartmentId = d.DepartmentId) AS 'Calls', + (SELECT COUNT (*) FROM PersonnelRoles pr WHERE pr.DepartmentId = d.DepartmentId) AS 'Roles', + (SELECT COUNT (*) FROM DepartmentNotifications dn WHERE dn.DepartmentId = d.DepartmentId) AS 'Notifications', + (SELECT COUNT (*) FROM UnitTypes ut WHERE ut.DepartmentId = d.DepartmentId) AS 'UnitTypes', + (SELECT COUNT (*) FROM CallTypes ct WHERE ct.DepartmentId = d.DepartmentId) AS 'CallTypes', + (SELECT COUNT (*) FROM DepartmentCertificationTypes dct WHERE dct.DepartmentId = d.DepartmentId) AS 'CertTypes', + CASE + WHEN d.TimeZone IS NOT NULL OR d.Use24HourTime IS NOT NULL OR d.AddressId IS NOT NULL + THEN 1 + ELSE 0 + END AS 'Settings' + FROM Departments d + WHERE d.DepartmentId = %DID%"; + SelectDepartmentByNameQuery = @" + SELECT %SCHEMA%.%DEPARTMENTSTABLE%.*, %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.* + FROM %SCHEMA%.%DEPARTMENTSTABLE% + LEFT JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% ON %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.DepartmentId = %SCHEMA%.%DEPARTMENTSTABLE%.DepartmentId + WHERE Name = %NAME%"; + SelectDepartmentByUsernameQuery = @"SELECT d.*, dm.* + FROM %SCHEMA%.%USERSTABLE% u + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm1 ON dm1.UserId = u.Id + INNER JOIN %SCHEMA%.%DEPARTMENTSTABLE% d ON d.DepartmentId = dm1.DepartmentId + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.DepartmentId = d.DepartmentId + WHERE u.UserName = %USERNAME% AND d.DepartmentId = dm.DepartmentId AND dm.IsDeleted = false AND (dm.IsActive = true OR dm.IsDefault = true)"; + SelectDepartmentByUserIdQuery = @"SELECT d.*, dm.* + FROM %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm1 + INNER JOIN %SCHEMA%.%DEPARTMENTSTABLE% d ON d.DepartmentId = dm1.DepartmentId + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.DepartmentId = d.DepartmentId + WHERE dm.UserId = %USERID% AND d.DepartmentId = dm.DepartmentId AND dm.IsDeleted = false AND (dm.IsActive = true OR dm.IsDefault = true)"; + SelectValidDepartmentByUsernameQuery = + @"SELECT dm.UserId as UserId, dm.IsDisabled as IsDisabled, dm.IsDeleted as IsDeleted, d.DepartmentId as DepartmentId, d.Code as Code + FROM %SCHEMA%.%USERSTABLE% u + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.UserId = u.Id + INNER JOIN %SCHEMA%.%DEPARTMENTSTABLE% d ON dm.DepartmentId = d.DepartmentId + WHERE u.UserName = %USERNAME% AND dm.IsActive = true"; + SelectDepartmentStatsByUserDidQuery = @" + SELECT + (SELECT COUNT(*) FROM %SCHEMA%.%MESSAGESTABLE% m + LEFT OUTER JOIN %SCHEMA%.%MESSAGERECIPIENTSTABLE% mr ON m.MessageId = mr.MessageId + WHERE mr.UserId = %USERID% AND mr.IsDeleted = false AND m.IsDeleted = false) AS UnreadMessageCount, + + (SELECT COUNT(*) FROM %SCHEMA%.%CALLTABLENAME% c WHERE c.DepartmentId = %DID% AND c.IsDeleted = false AND c.State = 0) AS OpenCallsCount"; + + #endregion Departments + + #region Personnel Roles + + PersonnelRolesTable = "PersonnelRoles"; + PersonnelRoleUsersTable = "PersonnelRoleUsers"; + SelectRoleByDidAndNameQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND Name = %NAME%"; + SelectRolesByDidAndUserQuery = @" + SELECT * FROM %SCHEMA%.%PERSONNELROLESTABLE% pr + INNER JOIN %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru ON pr.PersonnelRoleId = pru.PersonnelRoleId + WHERE pru.UserId = %USERID% AND pr.DepartmentId = %DID%"; + //SelectRoleUsersByRoleQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE PersonnelRoleId = %ROLEID%"; + SelectRoleUsersByRoleQuery = @" + SELECT * FROM %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.UserId = pru.UserId AND dm.DepartmentId = pru.DepartmentId + WHERE pru.PersonnelRoleId = %ROLEID% AND dm.IsDisabled = false AND dm.IsDeleted = false"; + + SelectRoleUsersByUserQuery = @" + SELECT * FROM %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru + INNER JOIN %SCHEMA%.%PERSONNELROLESTABLE% pr ON pru.PersonnelRoleId = pr.PersonnelRoleId + WHERE pru.UserId = %USERID% AND pr.DepartmentId = %DID%"; + SelectRoleUsersByDidQuery = @" + SELECT * FROM %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru + INNER JOIN %SCHEMA%.%PERSONNELROLESTABLE% pr ON pru.PersonnelRoleId = pr.PersonnelRoleId + WHERE pr.DepartmentId = %DID%"; + SelectRolesByDidQuery = @" + SELECT pr.*, pru.* + FROM %SCHEMA%.%ROLESTABLE% pr + LEFT JOIN %SCHEMA%.%ROLEUSERSTABLE% pru ON pr.PersonnelRoleId = pru.PersonnelRoleId + WHERE pr.DepartmentId = %DID%"; + SelectRolesByRoleIdQuery = @" + SELECT pr.*, pru.* + FROM %SCHEMA%.%ROLESTABLE% pr + LEFT JOIN %SCHEMA%.%ROLEUSERSTABLE% pru ON pr.PersonnelRoleId = pru.PersonnelRoleId + WHERE pr.PersonnelRoleId = %ROLEID%"; + + #endregion Personnel Roles + + #region Inventory + + InventoryTable = "Inventories"; + InventoryTypesTable = "InventoryTypes"; + SelectInventoryByTypeIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE TypeId = %TYPEID%"; + SelectInventoryByDIdQuery = @" + SELECT i.*, it.* + FROM %SCHEMA%.%INVENTORYTABLE% i + INNER JOIN %SCHEMA%.%INVENTORYTYPESTABE% it ON it.InventoryTypeId = i.TypeId + WHERE i.DepartmentId = %DID%"; + SelectInventoryByInventoryIdQuery = @" + SELECT i.*, it.* + FROM %SCHEMA%.%INVENTORYTABLE% i + INNER JOIN %SCHEMA%.%INVENTORYTYPESTABE% it ON it.InventoryTypeId = i.TypeId + WHERE i.InventoryId = %INVENTORYID%"; + DeleteInventoryByGroupIdQuery = @" + DELETE FROM %SCHEMA%.%TABLENAME% + WHERE DepartmentId = %DID% AND GroupId = %ID%"; + #endregion Inventory + + #region Messages + + MessagesTable = "Messages"; + MessageRecipientsTable = "MessageRecipients"; + SelectInboxMessagesByUserQuery = @" + SELECT m.*, mr.* + FROM %SCHEMA%.%MESSAGESTABLE% m + LEFT JOIN %SCHEMA%.%MESSAGERECIPIENTSTABLE% mr ON mr.MessageId = m.MessageId + WHERE mr.UserId = %USERID% AND mr.IsDeleted = false"; + SelectUnreadMessageCountQuery = @" + SELECT COUNT(*) FROM %SCHEMA%.%MESSAGESTABLE% m + LEFT OUTER JOIN %SCHEMA%.%MESSAGERECIPIENTSTABLE% mr ON m.MessageId = mr.MessageId + WHERE mr.UserId = %USERID% AND mr.IsDeleted = false AND m.IsDeleted = false"; + SelectMessageRecpByMessageUsQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE MessageId = %MESSAGEID% AND UserId = %USERID%"; + SelectMessagesByUserQuery = @" + SELECT %SCHEMA%.%MESSAGESTABLE%.*, %SCHEMA%.%MESSAGERECIPIENTSTABLE%.* + FROM %SCHEMA%.%MESSAGESTABLE% + LEFT JOIN %SCHEMA%.%MESSAGERECIPIENTSTABLE% ON %SCHEMA%.%MESSAGERECIPIENTSTABLE%.MessageId = %SCHEMA%.%MESSAGESTABLE%.MessageId + WHERE ReceivingUserId = %USERID% OR SendingUserId = %USERID%"; + SelectMessageRecpsByUserQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID%"; + SelectMessageByIdQuery = @" + SELECT m.*, mr.* + FROM %SCHEMA%.%MESSAGESTABLE% m + LEFT JOIN %SCHEMA%.%MESSAGERECIPIENTSTABLE% mr ON mr.MessageId = m.MessageId + WHERE m.MessageId = %MESSAGEID%"; + SelectSentMessagesByUserQuery = @" + SELECT m.*, mr.* + FROM %SCHEMA%.%MESSAGESTABLE% m + LEFT JOIN %SCHEMA%.%MESSAGERECIPIENTSTABLE% mr ON mr.MessageId = m.MessageId + WHERE m.SendingUserId = %USERID% AND m.IsDeleted = false"; + UpdateRecievedMessagesAsDeletedQuery = @" + UPDATE %SCHEMA%.%TABLENAME% + SET IsDeleted = true + WHERE MessageId IN (%MESSAGEIDS%) AND UserId = %USERID%"; + UpdateRecievedMessagesAsReadQuery = @" + UPDATE %SCHEMA%.%TABLENAME% + SET ReadOn = %READON% + WHERE MessageId IN (%MESSAGEIDS%) AND UserId = %USERID%"; + + #endregion Messages + + #region Identity + + InsertRoleQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%)"; + DeleteRoleQuery = "DELETE FROM %SCHEMA%.%TABLENAME% WHERE Id = %ID%"; + UpdateRoleQuery = "UPDATE %SCHEMA%.%TABLENAME% %SETVALUES% WHERE Id = %ID%"; + SelectRoleByNameQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE Name = %NAME%"; + SelectRoleByIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE Id = %ID%"; + InsertUserQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% OUTPUT INSERTED.Id VALUES(%VALUES%)"; + DeleteUserQuery = "DELETE FROM %SCHEMA%.%TABLENAME% WHERE Id = %ID%"; + UpdateUserQuery = "UPDATE %SCHEMA%.%TABLENAME% %SETVALUES% WHERE Id = %ID%"; + SelectUserByUserNameQuery = + "SELECT %SCHEMA%.%USERTABLE%.*, %SCHEMA%.%USERROLETABLE%.* FROM %SCHEMA%.%USERTABLE% LEFT JOIN %SCHEMA%.%USERROLETABLE% ON %SCHEMA%.%USERROLETABLE%.UserId = %SCHEMA%.%USERTABLE%.Id WHERE UserName = %USERNAME%"; + SelectUserByEmailQuery = + "SELECT %SCHEMA%.%USERTABLE%.*, %SCHEMA%.%USERROLETABLE%.* FROM %SCHEMA%.%USERTABLE% LEFT JOIN %SCHEMA%.%USERROLETABLE% ON %SCHEMA%.%USERROLETABLE%.UserId = %SCHEMA%.%USERTABLE%.Id WHERE Email = %EMAIL%"; + SelectUserByIdQuery = + "SELECT %SCHEMA%.%USERTABLE%.*, %SCHEMA%.%USERROLETABLE%.* FROM %SCHEMA%.%USERTABLE% LEFT JOIN %SCHEMA%.%USERROLETABLE% ON %SCHEMA%.%USERROLETABLE%.UserId = %SCHEMA%.%USERTABLE%.Id WHERE %SCHEMA%.%USERTABLE%.Id = %ID%"; + InsertUserClaimQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%)"; + InsertUserLoginQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%)"; + InsertUserRoleQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%)"; + GetUserLoginByLoginProviderAndProviderKeyQuery = + "SELECT %USERFILTER%, %SCHEMA%.%USERROLETABLE%.* FROM %SCHEMA%.%USERTABLE% LEFT JOIN %SCHEMA%.%USERROLETABLE% ON %SCHEMA%.%USERROLETABLE%.UserId = %SCHEMA%.%USERTABLE%.Id INNER JOIN %SCHEMA%.%USERLOGINTABLE% ON %SCHEMA%.%USERTABLE%.Id = %SCHEMA%.%USERLOGINTABLE%.UserId WHERE LoginProvider = @LoginProvider AND ProviderKey = @ProviderKey limit 1"; + GetClaimsByUserIdQuery = "SELECT ClaimType, ClaimValue FROM %SCHEMA%.%TABLENAME% WHERE UserId = %ID%"; + GetRolesByUserIdQuery = + "SELECT Name FROM %SCHEMA%.%ROLETABLE%, %SCHEMA%.%USERROLETABLE% WHERE UserId = %ID% AND %SCHEMA%.%ROLETABLE%.Id = %SCHEMA%.%USERROLETABLE%.RoleId"; + GetUserLoginInfoByIdQuery = + "SELECT LoginProvider, Name, ProviderKey FROM %SCHEMA%.%TABLENAME% WHERE UserId = %ID%"; + GetUsersByClaimQuery = + "SELECT %USERFILTER% FROM %SCHEMA%.%USERTABLE%, %SCHEMA%.%USERCLAIMTABLE% WHERE ClaimValue = %CLAIMVALUE% AND ClaimType = %CLAIMTYPE%"; + GetUsersInRoleQuery = + "SELECT %USERFILTER% FROM %SCHEMA%.%USERTABLE%, %SCHEMA%.%USERROLETABLE%, %SCHEMA%.%ROLETABLE% WHERE %SCHEMA%.%ROLETABLE%.Name = %ROLENAME% AND %SCHEMA%.%USERROLETABLE%.RoleId = %SCHEMA%.%ROLETABLE%.Id AND %SCHEMA%.%USERROLETABLE%.UserId = %SCHEMA%.%USERTABLE%.Id"; + IsInRoleQuery = + "SELECT 1 FROM %SCHEMA%.%USERTABLE%, %SCHEMA%.%USERROLETABLE%, %SCHEMA%.%ROLETABLE% WHERE %SCHEMA%.%ROLETABLE%.Name = %ROLENAME% AND %SCHEMA%.%USERTABLE%.Id = %USERID% AND %SCHEMA%.%USERROLETABLE%.RoleId = %SCHEMA%.%ROLETABLE%.Id AND %SCHEMA%.%USERROLETABLE%.UserId = %SCHEMA%.%USERTABLE%.Id"; + RemoveClaimsQuery = + "DELETE FROM %SCHEMA%.%TABLENAME% WHERE UserId = %ID% AND ClaimType = %CLAIMTYPE% AND ClaimValue = %CLAIMVALUE%"; + RemoveUserFromRoleQuery = + "DELETE FROM %SCHEMA%.%USERROLETABLE% WHERE UserId = %USERID% AND RoleId = (SELECT Id FROM %SCHEMA%.%ROLETABLE% WHERE Name = %ROLENAME%)"; + RemoveLoginForUserQuery = + "DELETE FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID% AND LoginProvider = %LOGINPROVIDER% AND ProviderKey = %PROVIDERKEY%"; + UpdateClaimForUserQuery = + "UPDATE %SCHEMA%.%TABLENAME% SET ClaimType = %NEWCLAIMTYPE%, ClaimValue = %NEWCLAIMVALUE% WHERE UserId = %USERID% AND ClaimType = %CLAIMTYPE% AND ClaimValue = %CLAIMVALUE%"; + SelectClaimByRoleQuery = + "SELECT %SCHEMA%.%ROLECLAIMTABLE%.* FROM %SCHEMA%.%ROLETABLE%, %SCHEMA%.%ROLECLAIMTABLE% WHERE RoleId = %ROLEID% AND %SCHEMA%.%ROLECLAIMTABLE%.RoleId = %SCHEMA%.%ROLETABLE%.Id"; + InsertRoleClaimQuery = "INSERT INTO %SCHEMA%.%TABLENAME% %COLUMNS% VALUES(%VALUES%)"; + DeleteRoleClaimQuery = + "DELETE FROM %SCHEMA%.%TABLENAME% WHERE RoleId = %ROLEID% AND ClaimType = %CLAIMTYPE% AND ClaimValue = %CLAIMVALUE%"; + RoleTable = "AspNetRoles"; + UserTable = "AspNetUsers"; + UserClaimTable = "AspNetUserClaims"; + UserRoleTable = "AspNetUserRoles"; + UserLoginTable = "AspNetUserLogins"; + RoleClaimTable = "AspNetRoleClaims"; + + #endregion Identity + + #region Resource Orders + + ResourceOrdersTable = "ResourceOrders"; + ResourceOrderFillsTable = "ResourceOrderFills"; + ResourceOrderItemsTable = "ResourceOrderItems"; + ResourceOrderSettingsTable = "ResourceOrderSettings"; + ResourceOrderFillUnitsTable = "ResourceOrderFillUnits"; + SelectAllOpenOrdersQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CloseDate IS NULL"; + UpdateOrderFillStatusQuery = "UPDATE %SCHEMA%.%TABLENAME% %SETVALUES% WHERE ResourceOrderFillId = %ID%"; + SelectAllOpenNonDVisibleOrdersQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CloseDate IS NULL AND Visibility = false AND DepartmentId != %DID% AND NeededBy > %DATE%"; + SelectAllItemsByOrderIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE ResourceOrderId = %ID%"; + SelectItemsByResourceOrderIdQuery = @" + SELECT roi.*, rof.* + FROM %SCHEMA%.%RESOURCEORDERITEMSTABLE% roi + INNER JOIN %SCHEMA%.%RESOURCEORDERFILLSTABLE% rof ON roi.ResourceOrderItemId = rof.ResourceOrderItemId + WHERE roi.ResourceOrderId = %RESOURCEORDERID%"; + SelectOrderFillUnitsByFillIdQuery = @" + SELECT rofu.*, u.* + FROM %SCHEMA%.%RESOURCEORDERFILLUNIT% rofu + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = rofu.UnitId + WHERE rofu.ResourceOrderFillId = %FILLID%"; + #endregion Resource Orders + + #region Distribution Lists + + DistributionListsTable = "DistributionLists"; + DistributionListMembersTable = "DistributionListMembers"; + SelectDListByEmailQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE EmailAddress = %EMAIL%"; + SelectAllEnabledDListsQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE IsDisabled = false"; + SelectDListMembersByListIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DistributionListId = %LISTID%"; + SelectDListMembersByUserQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID%"; + SelectDListByIdQuery = @" + SELECT dl.*, dlm.* + FROM %SCHEMA%.%DISTRIBUTIONLISTSTABLE% dl + LEFT JOIN %SCHEMA%.%DISTRIBUTIONLISTMEMBERSTABLE% dlm ON dlm.DistributionListId = dl.DistributionListId + WHERE dl.DistributionListId = %LISTID%"; + SelectDListsByDIdQuery = @" + SELECT dl.*, dlm.* + FROM %SCHEMA%.%DISTRIBUTIONLISTSTABLE% dl + LEFT JOIN %SCHEMA%.%DISTRIBUTIONLISTMEMBERSTABLE% dlm ON dlm.DistributionListId = dl.DistributionListId + WHERE dl.DepartmentId = %DID%"; + + #endregion Distribution Lists + + #region Custom States + + CustomStatesTable = "CustomStates"; + CustomStateDetailsTable = "CustomStateDetails"; + SelectStatesByDidUserQuery = @" + SELECT %SCHEMA%.%CUSTOMSTATESTABLE%.*, %SCHEMA%.%CUSTOMSTATEDETAILSTABLE%.* + FROM %SCHEMA%.%CUSTOMSTATESTABLE% + LEFT JOIN %SCHEMA%.%CUSTOMSTATEDETAILSTABLE% ON %SCHEMA%.%CUSTOMSTATEDETAILSTABLE%.CustomStateId = %SCHEMA%.%CUSTOMSTATESTABLE%.CustomStateId + WHERE DepartmentId = %DID%"; + SelectStatesByIdQuery = @" + SELECT cs.*, csd.* + FROM %SCHEMA%.%CUSTOMSTATESTABLE% cs + LEFT JOIN %SCHEMA%.%MCUSTOMSTATEDETAILSTABLE% csd ON csd.CustomStateId = cs.CustomStateId + WHERE cs.CustomStateId = %CUSTOMSTATEID%"; + + #endregion Custom States + + #region Training + + TrainingsTable = "Trainings"; + TrainingAttachmentsTable = "TrainingAttachments"; + TrainingUsersTable = "TrainingUsers"; + TrainingQuestionsTable = "TrainingQuestions"; + TrainingQuestionAnswersTable = "TrainingQuestionAnswers"; + SelectTrainingUserByTandUIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE TrainingId = %TRAININGID% AND UserId = %USERID%"; + SelectTrainingsByDIdQuery = @" + SELECT t.*, tu.* + FROM %SCHEMA%.%TRAININGSTABLE% t + LEFT OUTER JOIN %SCHEMA%.%TRAININGUSERSTABLE% tu ON tu.TrainingId = t.TrainingId + WHERE t.DepartmentId = %DID%"; + SelectTrainingQuestionsByTrainIdQuery = @" + SELECT tq.*, tqa.* + FROM %SCHEMA%.%TRAININGQUESTIONSTABLE% tq + LEFT OUTER JOIN %SCHEMA%.%TRAININGQUESTIONANSWERSTABLE% tqa ON tqa.TrainingQuestionId = tq.TrainingQuestionId + WHERE tq.TrainingId = %TRAININGID%"; + SelectTrainingByIdQuery = @" + SELECT t.*, tu.* + FROM %SCHEMA%.%TRAININGSTABLE% t + LEFT OUTER JOIN %SCHEMA%.%TRAININGUSERSTABLE% tu ON tu.TrainingId = t.TrainingId + WHERE t.TrainingId = %TRAININGID%"; + SelectTrainingAttachmentsBytIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE TrainingId = %TRAININGID%"; + + #endregion Training + + #region User Profile + + UserProfilesTable = "UserProfiles"; + SelectProfileByUserIdQuery = @" + SELECT %SCHEMA%.%USERPROFILESTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%USERPROFILESTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%USERPROFILESTABLE%.UserId + WHERE UserId = %USERID%"; + SelectProfileByMobileQuery = @" + SELECT %SCHEMA%.%USERPROFILESTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%USERPROFILESTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%USERPROFILESTABLE%.UserId + WHERE MobileNumber = %MOBILENUMBER%"; + SelectProfileByHomeQuery = @" + SELECT %SCHEMA%.%USERPROFILESTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%USERPROFILESTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%USERPROFILESTABLE%.UserId + WHERE HomeNumber = %HOMENUMBER%"; + SelectProfilesByIdsQuery = @" + SELECT %SCHEMA%.%USERPROFILESTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%USERPROFILESTABLE% + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%USERPROFILESTABLE%.UserId + WHERE UserId IN (%USERIDS%)"; + SelectAllProfilesByDIdQuery = @" + SELECT %SCHEMA%.%USERPROFILESTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%USERPROFILESTABLE% + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% ON %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId = %SCHEMA%.%USERPROFILESTABLE%.UserId + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%USERPROFILESTABLE%.UserId + WHERE DepartmentId = %DID%"; + SelectAllNonDeletedProfilesByDIdQuery = @" + SELECT %SCHEMA%.%USERPROFILESTABLE%.*, %SCHEMA%.%ASPNETUSERSTABLE%.Email as MembershipEmail, %SCHEMA%.%ASPNETUSERSTABLE%.* + FROM %SCHEMA%.%USERPROFILESTABLE% + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% ON %SCHEMA%.%DEPARTMENTMEMBERSTABLE%.UserId = %SCHEMA%.%USERPROFILESTABLE%.UserId + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% ON %SCHEMA%.%ASPNETUSERSTABLE%.Id = %SCHEMA%.%USERPROFILESTABLE%.UserId + WHERE DepartmentId = %DID% AND IsDeleted = false"; + + #endregion User Profile + + #region Calendar + + CalendarItemsTable = "CalendarItems"; + CalendarItemAttendeesTable = "CalendarItemAttendees"; + CalendarItemTypesTable = "CalendarItemTypes"; + SelectCalendarItemByRecurrenceIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE RecurrenceId = %ID%"; + DeleteCalendarItemQuery = + "DELETE FROM %SCHEMA%.%TABLENAME% WHERE CalendarItemId = %ID% OR RecurrenceId = %ID%"; + SelectCalendarItemAttendeeByUserQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CalendarItemId = %ID% AND UserId = %USERID%"; + SelectCalendarItemsByDateQuery = @"SELECT * FROM %SCHEMA%.%TABLENAME% + WHERE IsV2Schedule = true AND ReminderSent = false AND Reminder > 0 + AND (Start >= @startDate OR (RecurrenceType > 0 AND (RecurrenceEnd IS NULL OR RecurrenceEnd > %STARTDATE%)))"; + SelectCalendarItemByIdQuery = @" + SELECT ci.*, cia.* + FROM %SCHEMA%.%CALENDARITEMSTABLE% ci + LEFT OUTER JOIN %SCHEMA%.%CALITEMATTENDEESTABLE% cia ON cia.CalendarItemId = ci.CalendarItemId + WHERE ci.CalendarItemId = %CALENDARITEMID%"; + SelectCalendarItemByDIdQuery = @" + SELECT ci.*, cia.* + FROM %SCHEMA%.%CALENDARITEMSTABLE% ci + LEFT OUTER JOIN %SCHEMA%.%CALITEMATTENDEESTABLE% cia ON cia.CalendarItemId = ci.CalendarItemId + WHERE ci.DepartmentId = %DID%"; + #endregion Calendar + + #region Logs + + LogsTable = "Logs"; + LogUsersTable = "LogUsers"; + LogUnitsTable = "LogUnits"; + CallLogsTable = "CallLogs"; + LogAttachmentsTable = "LogAttachments"; + SelectLogsByUserIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE LoggedByUserId = %USERID%"; + SelectCallLogsByUserIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE LoggedByUserId = %USERID%"; + SelectLogsByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectLogsByGroupIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE StationGroupId = %GROUPID%"; + SelectCallLogsByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectLogUsersByLogIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE LogId = %LOGID%"; + SelectLogUnitsByLogIdQuery = @" + SELECT lu.*, u.* + FROM %SCHEMA%.%LOGUNITSTABLE% lu + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = lu.UnitId + WHERE lu.LogId = %LOGID%"; + SelectLogYearsByDeptQuery = @" + SELECT extract(year from l.LoggedOn) + FROM Logs l WHERE l.DepartmentId = %DID% + group by 1 + ORDER BY 1 DESC"; + SelecAllLogsByDidYearQuery = @" + SELECT * FROM %SCHEMA%.%TABLENAME% + WHERE DepartmentId = %DID% AND extract(year from LoggedOn) = %YEAR% + ORDER BY LoggedOn DESC"; + + #endregion Logs + + #region Units + + UnitsTable = "Units"; + UnitLogsTable = "UnitLogs"; + UnitRolesTable = "UnitRoles"; + UnitTypesTable = "UnitTypes"; + UnitStatesTable = "UnitStates"; + UnitStateRolesTable = "UnitStateRoles"; + UnitLocationsTable = "UnitLocations"; + UnitActiveRolesTable = "UnitActiveRoles"; + SelectUnitStatesByUnitIdQuery = @" + SELECT us.*, u.* + FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = us.UnitId + WHERE us.UnitId = %UNITID%"; + SelectLastUnitStateByUnitIdQuery = @" + SELECT us.*, u.* + FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = us.UnitId + WHERE us.UnitId = %UNITID% + ORDER BY UnitStateId DESC"; + SelectLastUnitStateByUnitIdTimeQuery = @" + SELECT us.*, u.* + FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = us.UnitId + WHERE us.UnitId = %UNITID% AND us.UnitStateId > %UNITSTATEID% + ORDER BY Timestamp DESC"; + SelectUnitByDIdNameQuery = @" + SELECT * FROM %SCHEMA%.%TABLENAME% + WHERE DepartmentId = %DID% AND Name = %UNITNAME%"; + SelectUnitTypeByDIdNameQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND Type = %TYPENAME%"; + SelectUnitLogsByUnitIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UnitId = %UNITID% ORDER BY Timestamp DESC"; + SelectUnitRolesByUnitIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UnitId = %UNITID%"; + SelectUnitsByGroupIdQuery = @" + SELECT u.*, dg.* + FROM %SCHEMA%.%UNITSTABLE% u + INNER JOIN %SCHEMA%.%DEPARTMENTGROUPSTABLE% dg ON dg.DepartmentGroupId = u.StationGroupId + WHERE u.StationGroupId = %GROUPID%"; + SelectCurrentRolesByUnitIdQuery = @" + SELECT * FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTATEROLESSTABLE% ON %SCHEMA%.%UNITSTATEROLESSTABLE%.UnitStateId = us.UnitStateId + WHERE us.UnitId = @unitId AND Timestamp >= (SELECT timezone('utc', now()) + INTERVAL '-2 day')"; + SelectLatestUnitLocationByUnitId = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UnitId = %UNITID% ORDER BY UnitLocationId DESC limit 1"; + SelectLatestUnitLocationByUnitIdTimeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UnitId = %UNITID% AND Timestamp > %TIMESTAMP% ORDER BY UnitLocationId DESC limit 1"; + SelectUnitStatesByCallIdQuery = @" + SELECT us.*, u.* + FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = us.UnitId + WHERE us.DestinationId = %CALLID%"; + SelectUnitByDIdTypeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND Type = %TYPE%"; + SelectLastUnitStatesByDidQuery = @" + SELECT q.*, u.* + FROM ( + SELECT *, ROW_NUMBER() OVER (PARTITION BY UnitId ORDER BY UnitStateId DESC) us + FROM UnitStates + ) q + INNER JOIN Units u ON u.UnitId = q.UnitId + WHERE u.DepartmentId = %DID% AND us = 1"; + SelectUnitStateByUnitStateIdQuery = @" + SELECT us.*, u.* + FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = us.UnitId + WHERE us.UnitStateId = %UNITSTATEID%"; + SelectUnitActiveRolesByUnitIdQuery = @"SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UnitId = %UNITID%"; + DeleteUnitActiveRolesByUnitIdQuery = @"DELETE FROM %SCHEMA%.%TABLENAME% WHERE UnitId = %UNITID%"; + SelectActiveRolesForUnitsByDidQuery = @"SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID%"; + SelectUnitsByDIdQuery = @" + SELECT u.*, ur.* + FROM %SCHEMA%.%UNITSTABLE% u + LEFT JOIN %SCHEMA%.%UNITROLESTABLE% ur ON ur.UnitId = u.UnitId + WHERE u.DepartmentId = %DID%"; + + #endregion Units + + #region Shifts + + ShiftsTable = "Shifts"; + ShiftPersonsTable = "ShiftPersons"; + ShiftDaysTable = "ShiftDays"; + ShiftGroupsTable = "ShiftGroups"; + ShiftSignupsTable = "ShiftSignups"; + ShiftSignupTradesTable = "ShiftSignupTrades"; + ShiftSignupTradeUsersTable = "ShiftSignupTradeUsers"; + ShiftSignupTradeUserShiftsTable = "ShiftSignupTradeUserShifts"; + ShiftStaffingsTable = "ShiftStaffings"; + ShiftStaffingPersonsTable = "ShiftStaffingPersons"; + ShiftGroupRolesTable = "ShiftGroupRoles"; + ShiftGroupAssignmentsTable = "ShiftGroupAssignments"; + SelectShiftStaffingByDayQuery = @" + SELECT %SCHEMA%.%SHIFTSTAFFINGSTABLE%.*, %SCHEMA%.%SHIFTSTAFFINGPERSONSTABLE%.* + FROM %SCHEMA%.%SHIFTSTAFFINGSTABLE% + LEFT JOIN %SCHEMA%.%SHIFTSTAFFINGPERSONSTABLE% ON %SCHEMA%.%SHIFTSTAFFINGPERSONSTABLE%.ShiftStaffingId = %SCHEMA%.%SHIFTSTAFFINGSTABLE%.ShiftStaffingId + WHERE ShiftId = %SHIFTID% AND ShiftDay = %SHIFTDAY%"; + SelectShiftGroupByGroupQuery = @" + SELECT %SCHEMA%.%SHIFTGROUPSTABLE%.*, %SCHEMA%.%SHIFTGROUPROLESTABLE%.* + FROM %SCHEMA%.%SHIFTGROUPSTABLE% + LEFT JOIN %SCHEMA%.%SHIFTGROUPROLESTABLE% ON %SCHEMA%.%SHIFTGROUPROLESTABLE%.ShiftGroupId = %SCHEMA%.%SHIFTGROUPSTABLE%.ShiftGroupId + WHERE DepartmentGroupId = %GROUPID%"; + SelectShiftAssignmentByGroupQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE ShiftGroupId = %SHIFTGROUPID%"; + SelectShiftSignupTradeUsersByTradeIdQuery = @" + SELECT %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.*, %SCHEMA%.%SHIFTSIGNUPTRADEUSERSHIFTSTABLE%.* + FROM %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE% + LEFT JOIN %SCHEMA%.%SHIFTSIGNUPTRADEUSERSHIFTSTABLE% ON %SCHEMA%.%SHIFTSIGNUPTRADEUSERSHIFTSTABLE%.ShiftSignupTradeUserId = %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.ShiftSignupTradeUserId + WHERE ShiftSignupTradeId = %SHIFTSIGNUPTRADEID%"; + SelectShiftSignupByShiftIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE ShiftId = %SHIFTID%"; + SelectShiftSignupTradeBySourceIdQuery = @" + SELECT %SCHEMA%.%SHIFTSIGNUPTRADESTABLE%.*, %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.* + FROM %SCHEMA%.%SHIFTSIGNUPTRADESTABLE% + LEFT JOIN %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE% ON %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.ShiftSignupTradeId = %SCHEMA%.%SHIFTSIGNUPTRADESTABLE%.ShiftSignupTradeId + WHERE SourceShiftSignupId = %SHIFTSIGNUPID%"; + SelectShiftSignupTradeByTargetIdQuery = @" + SELECT %SCHEMA%.%SHIFTSIGNUPTRADESTABLE%.*, %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.* + FROM %SCHEMA%.%SHIFTSIGNUPTRADESTABLE% + LEFT JOIN %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE% ON %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.ShiftSignupTradeId = %SCHEMA%.%SHIFTSIGNUPTRADESTABLE%.ShiftSignupTradeId + WHERE TargetShiftSignupId = %SHIFTSIGNUPID%"; + SelectShiftDaysByShiftIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE ShiftId = %SHIFTID%"; + SelectShiftAndDaysByShiftIdQuery = @" + SELECT s.*, sd.* + FROM %SCHEMA%.%SHIFTSTABLE% s + LEFT JOIN %SCHEMA%.%SHIFTDAYSTABLE% sd ON sd.ShiftId = s.ShiftId + WHERE s.ShiftId = %SHIFTID%"; + SelectShiftAndDaysQuery = @" + SELECT %SCHEMA%.%SHIFTSTABLE%.*, %SCHEMA%.%SHIFTDAYSTABLE%.* + FROM %SCHEMA%.%SHIFTSTABLE% + LEFT JOIN %SCHEMA%.%SHIFTDAYSTABLE% ON %SCHEMA%.%SHIFTDAYSTABLE%.ShiftId = %SCHEMA%.%SHIFTSTABLE%.ShiftId"; + SelectShiftAndDaysJSONQuery = @" + select json_agg(row_to_json(j)) as JsonResult + from ( + select *, ( + select row_to_json(d) from departments d where d.departmentid = sh.departmentid + ) department, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftGroupId', sg.shiftgroupid, + 'ShiftId', sg.shiftid, + 'DepartmentGroupId', sg.departmentgroupid, + 'shift', (SELECT row_to_json(s1) from shifts s1 where s1.shiftid = sg.shiftid), + 'departmentgroup', (SELECT row_to_json(dg1) from departmentgroups dg1 WHERE dg1.departmentgroupid = sg.departmentgroupid), + 'roles', (SELECT json_agg(row_to_json(sgr1)) from shiftgrouproles sgr1 WHERE sgr1.shiftgroupid = sg.shiftgroupid) + ) + ) + from shiftgroups sg + where sg.shiftid = sh.shiftid + ) groups, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftDayId', sd.shiftdayid, + 'ShiftId', sd.shiftid, + 'Day', sd.day, + 'shift', (SELECT row_to_json(s2) from shifts s2 where s2.shiftid = sd.shiftid) + ) + ) + from shiftdays sd + WHERE sd.shiftid = sh.shiftid + ) days, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftPersonId', sp.shiftpersonid, + 'ShiftId', sp.shiftid, + 'UserId', sp.userid, + 'shift', (SELECT row_to_json(s3) from shifts s3 where s3.shiftid = sp.shiftid) + ) + ) + FROM shiftpersons sp + WHERE sp.shiftid = sh.shiftid + ) personnel, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftAdminId', sa.shiftadminid, + 'ShiftId', sa.shiftid, + 'UserId', sa.userid, + 'shift', (SELECT row_to_json(s4) from shifts s4 where s4.shiftid = sa.shiftid) + ) + ) + FROM shiftadmins sa + WHERE sa.shiftid = sh.shiftid + ) admins, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftSignupId', ss.shiftsignupid, + 'ShiftId', ss.shiftid, + 'DepartmentGroupId', ss.departmentgroupid, + 'UserId', ss.userid, + 'SignupTimestamp', ss.signuptimestamp, + 'ShiftDay', ss.shiftday, + 'Denied', ss.denied, + 'shift', (SELECT row_to_json(s5) from shifts s5 where s5.shiftid = ss.shiftid), + 'departmentgroup', (SELECT row_to_json(dg2) from departmentgroups dg2 WHERE dg2.departmentgroupid = ss.departmentgroupid) + ) + ) + from shiftsignups ss + where ss.shiftid = sh.shiftid + ) + + from shifts sh + ) j"; + SelectShiftSignupByUserIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID%"; + SelectShiftSignupTradeByUserIdQuery = @" + SELECT %SCHEMA%.%SHIFTSIGNUPTRADESTABLE%.*, %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.* + FROM %SCHEMA%.%SHIFTSIGNUPTRADESTABLE% + LEFT JOIN %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE% ON %SCHEMA%.%SHIFTSIGNUPTRADEUSERSTABLE%.ShiftSignupTradeId = %SCHEMA%.%SHIFTSIGNUPTRADESTABLE%.ShiftSignupTradeId + WHERE UserId = %USERID%"; + SelectOpenShiftSignupTradesByUserIdQuery = @" + SELECT * + FROM ShiftSignupTrades sst + INNER JOIN ShiftSignupTradeUsers sstu ON sstu.ShiftSignupTradeId = sst.ShiftSignupTradeId + WHERE sst.UserId = %USERID% AND sst.UserId != %USERID% AND sst.TargetShiftSignupId IS NULL"; + SelectShiftAndDaysByDIdQuery = @" + SELECT s.*, sd.* + FROM %SCHEMA%.%SHIFTSTABLE% s + LEFT JOIN %SCHEMA%.%SHIFTDAYSTABLE% sd ON sd.ShiftId = s.ShiftId + WHERE s.DepartmentId = %DID%"; + SelectShiftByShiftIdQuery = @" + SELECT s.*, sp.* + FROM %SCHEMA%.%SHIFTSTABLE% s + LEFT JOIN %SCHEMA%.%SHIFTPERSONSTABLE% sp ON sp.ShiftId = s.ShiftId + WHERE s.ShiftId = %SHIFTID%"; + SelectShiftPersonByShiftIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE ShiftId = %SHIFTID%"; + SelectShiftGroupByShiftIdQuery = @" + SELECT sg.*, sgr.* + FROM %SCHEMA%.%SHIFTGROUPSTABLE% sg + LEFT JOIN %SCHEMA%.%SHIFTGROUPROLESTABLE% sgr ON sgr.ShiftGroupId = sg.ShiftGroupId + WHERE sg.ShiftId = %SHIFTID%"; + SelectShiftDayByIdQuery = @" + SELECT sd.*, s.* + FROM %SCHEMA%.%SHIFTDAYSTABLE% sd + INNER JOIN %SCHEMA%.%SHIFTSTABLE% s ON s.ShiftId = sd.ShiftId + WHERE sd.ShiftDayId = %SHIFTDAYID%"; + SelectShiftSignupByShiftIdDateQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE ShiftId = %SHIFTID% AND CAST(ShiftDay AS DATE) = CAST(%SHIFTDAYDATE% AS DATE)"; + SelectShiftGroupRolesByGroupIdQuery = @" + SELECT sgr.*, pr.* + FROM %SCHEMA%.%SHIFTGROUPROLESTABLE% sgr + INNER JOIN %SCHEMA%.%PERSONNELROLESTABLE% pr ON pr.PersonnelRoleId = sgr.PersonnelRoleId + WHERE sgr.ShiftGroupId = %SHIFTGROUPID%"; + SelectShiftTradeAndSourceByUserIdQuery = @" + SELECT st.*, ss.* + FROM %SCHEMA%.%SHIFTTRADESTABLE% st + INNER JOIN %SCHEMA%.%SHIFTSIGNUPSTABLE% ss ON ss.ShiftSignupId = st.SourceShiftSignupId + WHERE st.UserId = %USERID%"; + SelectShiftByShiftIdJSONQuery = @" + select json_agg(row_to_json(j)) as JsonResult + from ( + select *, ( + select row_to_json(d) from departments d where d.departmentid = sh.departmentid + ) department, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftGroupId', sg.shiftgroupid, + 'ShiftId', sg.shiftid, + 'DepartmentGroupId', sg.departmentgroupid, + 'shift', (SELECT row_to_json(s1) from shifts s1 where s1.shiftid = sg.shiftid), + 'departmentgroup', (SELECT row_to_json(dg1) from departmentgroups dg1 WHERE dg1.departmentgroupid = sg.departmentgroupid), + 'roles', (SELECT json_agg(row_to_json(sgr1)) from shiftgrouproles sgr1 WHERE sgr1.shiftgroupid = sg.shiftgroupid) + ) + ) + from shiftgroups sg + where sg.shiftid = sh.shiftid + ) groups, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftDayId', sd.shiftdayid, + 'ShiftId', sd.shiftid, + 'Day', sd.day, + 'shift', (SELECT row_to_json(s2) from shifts s2 where s2.shiftid = sd.shiftid) + ) + ) + from shiftdays sd + WHERE sd.shiftid = sh.shiftid + ) days, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftPersonId', sp.shiftpersonid, + 'ShiftId', sp.shiftid, + 'UserId', sp.userid, + 'shift', (SELECT row_to_json(s3) from shifts s3 where s3.shiftid = sp.shiftid) + ) + ) + FROM shiftpersons sp + WHERE sp.shiftid = sh.shiftid + ) personnel, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftAdminId', sa.shiftadminid, + 'ShiftId', sa.shiftid, + 'UserId', sa.userid, + 'shift', (SELECT row_to_json(s4) from shifts s4 where s4.shiftid = sa.shiftid) + ) + ) + FROM shiftadmins sa + WHERE sa.shiftid = sh.shiftid + ) admins, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftSignupId', ss.shiftsignupid, + 'ShiftId', ss.shiftid, + 'DepartmentGroupId', ss.departmentgroupid, + 'UserId', ss.userid, + 'SignupTimestamp', ss.signuptimestamp, + 'ShiftDay', ss.shiftday, + 'Denied', ss.denied, + 'shift', (SELECT row_to_json(s5) from shifts s5 where s5.shiftid = ss.shiftid), + 'departmentgroup', (SELECT row_to_json(dg2) from departmentgroups dg2 WHERE dg2.departmentgroupid = ss.departmentgroupid) + ) + ) + from shiftsignups ss + where ss.shiftid = sh.shiftid + ) + + from shifts sh + where sh.shiftid = %SHIFTID% + ) j"; + SelectShiftsByDidJSONQuery = @" + select json_agg(row_to_json(j)) as JsonResult + from ( + select *, ( + select row_to_json(d) from departments d where d.departmentid = sh.departmentid + ) department, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftGroupId', sg.shiftgroupid, + 'ShiftId', sg.shiftid, + 'DepartmentGroupId', sg.departmentgroupid, + 'shift', (SELECT row_to_json(s1) from shifts s1 where s1.shiftid = sg.shiftid), + 'departmentgroup', (SELECT row_to_json(dg1) from departmentgroups dg1 WHERE dg1.departmentgroupid = sg.departmentgroupid), + 'roles', (SELECT json_agg(row_to_json(sgr1)) from shiftgrouproles sgr1 WHERE sgr1.shiftgroupid = sg.shiftgroupid) + ) + ) + from shiftgroups sg + where sg.shiftid = sh.shiftid + ) groups, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftDayId', sd.shiftdayid, + 'ShiftId', sd.shiftid, + 'Day', sd.day, + 'shift', (SELECT row_to_json(s2) from shifts s2 where s2.shiftid = sd.shiftid) + ) + ) + from shiftdays sd + WHERE sd.shiftid = sh.shiftid + ) days, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftPersonId', sp.shiftpersonid, + 'ShiftId', sp.shiftid, + 'UserId', sp.userid, + 'shift', (SELECT row_to_json(s3) from shifts s3 where s3.shiftid = sp.shiftid) + ) + ) + FROM shiftpersons sp + WHERE sp.shiftid = sh.shiftid + ) personnel, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftAdminId', sa.shiftadminid, + 'ShiftId', sa.shiftid, + 'UserId', sa.userid, + 'shift', (SELECT row_to_json(s4) from shifts s4 where s4.shiftid = sa.shiftid) + ) + ) + FROM shiftadmins sa + WHERE sa.shiftid = sh.shiftid + ) admins, ( + SELECT + jsonb_agg( + jsonb_build_object( + 'ShiftSignupId', ss.shiftsignupid, + 'ShiftId', ss.shiftid, + 'DepartmentGroupId', ss.departmentgroupid, + 'UserId', ss.userid, + 'SignupTimestamp', ss.signuptimestamp, + 'ShiftDay', ss.shiftday, + 'Denied', ss.denied, + 'shift', (SELECT row_to_json(s5) from shifts s5 where s5.shiftid = ss.shiftid), + 'departmentgroup', (SELECT row_to_json(dg2) from departmentgroups dg2 WHERE dg2.departmentgroupid = ss.departmentgroupid) + ) + ) + from shiftsignups ss + where ss.shiftid = sh.shiftid + ) + + from shifts sh + where sh.departmentid = %DID% + ) j"; + SelectShiftSignupsByGroupIdAndDateQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentGroupId = %GROUPID% AND CAST(ShiftDay AS DATE) = CAST(%SHIFTDAYDATE% AS DATE)"; + + #endregion Shifts + + #region Dispatch Protocols + + DispatchProtocolsTable = "DispatchProtocols"; + DispatchProtocolTriggersTable = "DispatchProtocolTriggers"; + DispatchProtocolAttachmentsTable = "DispatchProtocolAttachments"; + DispatchProtocolQuestionsTable = "DispatchProtocolQuestions"; + DispatchProtocolQuestionAnswersTable = "DispatchProtocolQuestionAnswers"; + SelectProtocolByIdQuery = @" + SELECT p.*, pt.* + FROM %SCHEMA%.%PROTOCOLSTABLE% p + LEFT OUTER JOIN %SCHEMA%.%PROTOCOLTRIGGERSSTABLE% pt ON pt.DispatchProtocolId = p.DispatchProtocolId + WHERE p.DispatchProtocolId = %PROTOCOLID%"; + SelectProtocolsByDIdQuery = @" + SELECT p.*, pt.* + FROM %SCHEMA%.%PROTOCOLSTABLE% p + LEFT OUTER JOIN %SCHEMA%.%PROTOCOLTRIGGERSSTABLE% pt ON pt.DispatchProtocolId = p.DispatchProtocolId + WHERE p.DepartmentId = %DID%"; + SelectProtocolQuestionsByProIdQuery = @" + SELECT pq.*, pqa.* + FROM %SCHEMA%.%PROTOCOLQUESTIONSTABLE% pq + LEFT OUTER JOIN %SCHEMA%.%PROTOCOLQUESTIONANSWERSTABLE% pqa ON pqa.DispatchProtocolQuestionId = pq.DispatchProtocolQuestionId + WHERE pq.DispatchProtocolId = %PROTOCOLID%"; + SelectProtocolAttachmentsByProIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DispatchProtocolId = %PROTOCOLID%"; + SelectProtocolTriggersByProIdQuery = @" + SELECT * + FROM %SCHEMA%.%PROTOCOLTRIGGERSTABLE% pt + WHERE pt.DispatchProtocolId = %PROTOCOLID%"; + + #endregion Dispatch Protocols + + #region Calls + + CallsTable = "Calls"; + CallDispatchesTable = "CallDispatches"; + CallDispatchGroupsTable = "CallDispatchGroups"; + CallDispatchUnitsTable = "CallDispatchUnits"; + CallDispatchRolesTable = "CallDispatchRoles"; + CallTypesTable = "CallTypes"; + CallNotesTable = "CallNotes"; + CallAttachmentsTable = "CallAttachments"; + DepartmentCallPrioritiesTable = "DepartmentCallPriorities"; + CallProtocolsTable = "CallProtocols"; + SelectAllCallsByDidDateQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND IsDeleted = false AND LoggedOn >= %STARTDATE% AND LoggedOn <= %ENDDATE%"; + SelectAllClosedCallsByDidDateQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND IsDeleted = false AND State > 0"; + SelectAllCallDispatchesByGroupIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentGroupId = %GROUPID%"; + SelectCallAttachmentByCallIdTypeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID% AND CallAttachmentType = %TYPE%"; + SelectAllOpenCallsByDidDateQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND IsDeleted = false AND State = 0"; + SelectAllCallsByDidLoggedOnQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND AND LoggedOn >= %DATE%"; + UpdateUserDispatchesAsSentQuery = @" + UPDATE Calls + SET DispatchCount = (DispatchCount + 1), + LastDispatchedOn = GETUTCDATE() + WHERE CallId = %CALLID% + + UPDATE CallDispatches + SET DispatchCount = (DispatchCount + 1), + LastDispatchedOn = GETUTCDATE() + WHERE CallId = %CALLID% AND %USERIDS% LIKE '%|' +convert(varchar(max), UserId) + '|%'"; + SelectCallProtocolsByCallIdQuery = @" + SELECT %SCHEMA%.%CALLPROTOCOLSTABLE%.*, %SCHEMA%.%DISPATCHPROTOCOLSTABLE%.* + FROM %SCHEMA%.%CALLPROTOCOLSTABLE% + INNER JOIN %SCHEMA%.%DISPATCHPROTOCOLSTABLE% ON %SCHEMA%.%DISPATCHPROTOCOLSTABLE%.DispatchProtocolId = %SCHEMA%.%CALLPROTOCOLSTABLE%.DispatchProtocolId + WHERE CallId = %CALLID%"; + SelectAllCallDispatchesByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectCallAttachmentByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectAllCallGroupDispsByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectAllCallUnitDispsByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectAllCallRoleDispsByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectCallNotesByCallIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE CallId = %CALLID%"; + SelectCallYearsByDeptQuery = @" + SELECT extract(year from c.LoggedOn) + FROM Calls c WHERE c.DepartmentId = %DID% + group by 1 + ORDER BY 1 DESC"; + SelectAllClosedCallsByDidYearQuery = @" + SELECT * FROM %SCHEMA%.%TABLENAME% + WHERE DepartmentId = %DID% AND IsDeleted = false AND State > 0 AND extract(year from LoggedOn) = %YEAR% + ORDER BY LoggedOn DESC"; + SelectNonDispatchedScheduledCallsByDateQuery = @" + SELECT * + FROM %SCHEMA%.%TABLENAME% + WHERE HasBeenDispatched = false AND IsDeleted = false AND DispatchOn IS NOT NULL AND DispatchOn >= %STARTDATE% AND DispatchOn <= %ENDDATE%"; + SelectNonDispatchedScheduledCallsByDidQuery = @" + SELECT * + FROM %SCHEMA%.%TABLENAME% + WHERE HasBeenDispatched = false AND IsDeleted = false AND DepartmentId = %DID%"; + + #endregion Calls + + #region Department Groups + + DepartmentGroupsTable = "DepartmentGroups"; + DepartmentGroupMembersTable = "DepartmentGroupMembers"; + //SelectGroupMembersByGroupIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentGroupId = %GROUPID%"; + + SelectGroupMembersByGroupIdQuery = @" + SELECT dgm.* + FROM %SCHEMA%.%GROUPMEMBERSSTABLE% dgm + INNER JOIN %SCHEMA%.%GROUPSTABLE% dg ON dg.DepartmentGroupId = dgm.DepartmentGroupId + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.UserId = dgm.UserId AND dm.DepartmentId = dg.DepartmentId + WHERE dgm.DepartmentGroupId = %GROUPID% AND dm.IsDisabled = false AND dm.IsDeleted = false"; + + SelectGroupMembersByUserDidQuery = @" + SELECT dgm.*, dg.* + FROM %SCHEMA%.%GROUPMEMBERSSTABLE% dgm + INNER JOIN %SCHEMA%.%GROUPSTABLE% dg ON dg.DepartmentGroupId = dgm.DepartmentGroupId + WHERE dgm.UserId = %USERID% AND dgm.DepartmentId = %DID%"; + SelectAllGroupsByDidQuery = @" + SELECT dg.*, dgm.* + FROM %SCHEMA%.%GROUPSTABLE% dg + LEFT JOIN (SELECT dgm1.* + FROM %SCHEMA%.%GROUPMEMBERSSTABLE% dgm1 + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSSTABLE% dm ON dgm1.UserId = dm.UserId + WHERE dm.IsDeleted = false) AS dgm ON dgm.DepartmentGroupId = dg.DepartmentGroupId + WHERE dg.DepartmentId = %DID%"; + SelectAllGroupsByParentIdQuery = @" + SELECT %SCHEMA%.%GROUPSTABLE%.*, %SCHEMA%.%GROUPMEMBERSSTABLE%.* + FROM %SCHEMA%.%GROUPSTABLE% + LEFT JOIN %SCHEMA%.%GROUPMEMBERSSTABLE% ON %SCHEMA%.%GROUPMEMBERSSTABLE%.DepartmentGroupId = %SCHEMA%.%GROUPSTABLE%.DepartmentGroupId + WHERE ParentDepartmentGroupId = %GROUPID%"; + SelectGroupByDispatchCodeQuery = @" + SELECT %SCHEMA%.%GROUPSTABLE%.*, %SCHEMA%.%GROUPMEMBERSSTABLE%.* + FROM %SCHEMA%.%GROUPSTABLE% + LEFT JOIN %SCHEMA%.%GROUPMEMBERSSTABLE% ON %SCHEMA%.%GROUPMEMBERSSTABLE%.DepartmentGroupId = %SCHEMA%.%GROUPSTABLE%.DepartmentGroupId + WHERE DispatchEmail = %CODE%"; + SelectGroupByMessageCodeQuery = @" + SELECT %SCHEMA%.%GROUPSTABLE%.*, %SCHEMA%.%GROUPMEMBERSSTABLE%.* + FROM %SCHEMA%.%GROUPSTABLE% + LEFT JOIN %SCHEMA%.%GROUPMEMBERSSTABLE% ON %SCHEMA%.%GROUPMEMBERSSTABLE%.DepartmentGroupId = %SCHEMA%.%GROUPSTABLE%.DepartmentGroupId + WHERE MessageEmail = %CODE%"; + SelectGroupByGroupIdQuery = @" + SELECT dg.*, dgm.* + FROM %SCHEMA%.%GROUPSTABLE% dg + LEFT JOIN %SCHEMA%.%GROUPMEMBERSSTABLE% dgm ON dgm.DepartmentGroupId = dg.DepartmentGroupId + WHERE dg.DepartmentGroupId = %GROUPID%"; + DeleteGroupMembersByGroupIdDidQuery = @" + DELETE FROM %SCHEMA%.%TABLENAME% + WHERE DepartmentId = %DID% AND DepartmentGroupId = %ID%"; + SelectGroupAdminsByDidQuery = @" + SELECT dgm.*, dg.* + FROM %SCHEMA%.%GROUPMEMBERSSTABLE% dgm + INNER JOIN %SCHEMA%.%GROUPSTABLE% dg ON dg.DepartmentGroupId = dgm.DepartmentGroupId + WHERE dgm.IsAdmin = true AND dgm.DepartmentId = %DID%"; + #endregion Department Groups + + #region Payments + + PaymentsTable = "Payments"; + SelectGetDepartmentPlanCountsQuery = @" + SELECT + (SELECT COUNT(*) FROM DepartmentMembers dm WHERE dm.DepartmentId = %DID% AND IsDisabled = false AND IsDeleted = false) AS UsersCount, + (SELECT COUNT(*) FROM DepartmentGroups dg WHERE dg.DepartmentId = %DID%) AS GroupsCount, + (SELECT COUNT(*) FROM Units u WHERE u.DepartmentId = %DID%) AS UnitsCount"; + SelectPaymentByTransactionIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE TransactionId = %TRANSACTIONID%"; + SelectPaymentsByDIdQuery = @" + SELECT pa.*, pl.* + FROM %SCHEMA%.%PAYMENTSTSTABLE% pa + LEFT JOIN %SCHEMA%.%PLANSTABLE% pl ON pl.PlanId = pa.PlanId + WHERE pa.DepartmentId = %DID%"; + SelectPaymentByIdQuery = @" + SELECT pa.*, pl.* + FROM %SCHEMA%.%PAYMENTSTSTABLE% pa + LEFT JOIN %SCHEMA%.%PLANSTABLE% pl ON pl.PlanId = pa.PlanId + WHERE pa.PaymentId = %PAYMENTID%"; + + #endregion Payments + + #region User States + + UserStatesTable = "UserStates"; + SelectLatestUserStatesByDidQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND Timestamp >= %TIMESTAMP%"; + SelectUserStatesByUserIdQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID%"; + SelectLastUserStatesByUserIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID% ORDER BY UserStateId DESC limit 1"; + SelectPreviousUserStatesByUserIdQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE UserId = %USERID% AND UserStateId < %USERSTATEID% ORDER BY UserStateId DESC limit 1"; + SelectUserStatesByDIdDateRangeQuery = + "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE DepartmentId = %DID% AND Timestamp >= %STARTDATE% AND Timestamp <= %ENDDATE%"; + + #endregion User States + + #region Plans + + PlansTable = "Plans"; + PlanLimitsTable = "PlanLimits"; + SelectPlanByPlanIdQuery = @" + SELECT p.*, pl.* + FROM %SCHEMA%.%PLANSTABLE% p + INNER JOIN %SCHEMA%.%PLANLIMITS% pl ON pl.PlanId = p.PlanId + WHERE p.PlanId = %PLANID%"; + + #endregion Plans + + #region Mapping + + PoisTableName = "Pois"; + POITypesTableName = "POITypes"; + SelectPoiTypesByDIdQuery = @" + SELECT pt.*, p.* + FROM %SCHEMA%.%POITYPESTABLE% pt + LEFT JOIN %SCHEMA%.%POISTABLE% p ON pt.PoiTypeId = p.PoiTypeId + WHERE pt.DepartmentId = %DID%"; + SelectPoiTypeByIdQuery = @" + SELECT pt.*, p.* + FROM %SCHEMA%.%POITYPESTABLE% pt + LEFT JOIN %SCHEMA%.%POISTABLE% p ON pt.PoiTypeId = p.PoiTypeId + WHERE pt.PoiTypeId = %POITYPEID%"; + + #endregion Mapping + + #region Notes + + NotesTableName = "Notes"; + SelectNotesByDIdQuery = @" + SELECT n.*, d.* + FROM %SCHEMA%.%NOTESTABLE% n + INNER JOIN %SCHEMA%.%DEPARTMENTSTABLE% d ON d.DepartmentId = n.DepartmentId + WHERE n.DepartmentId = %DID%"; + + #endregion Notes + + #region Forms + + FormsTable = "Forms"; + FormAutomationsTable = "FormAutomations"; + SelectFormByIdQuery = @" + SELECT f.*, fa.* + FROM %SCHEMA%.%FORMSTABLE% f + LEFT OUTER JOIN %SCHEMA%.%FORMAUTOMATIONSTABLE% fa ON fa.FormId = f.FormId + WHERE f.FormId = %FORMID%"; + SelectFormsByDIdQuery = @" + SELECT f.*, fa.* + FROM %SCHEMA%.%FORMSTABLE% f + LEFT OUTER JOIN %SCHEMA%.%FORMAUTOMATIONSTABLE% fa ON fa.FormId = f.FormId + WHERE f.DepartmentId = %DID% AND IsDeleted = false"; + SelectFormAutomationsByFormIdQuery = @" + SELECT fa.* + FROM %SCHEMA%.%FORMAUTOMATIONSTABLE% fa + WHERE fa.FormId = %FORMID%"; + SelectNonDeletedFormsByDIdQuery = @" + SELECT f.*, fa.* + FROM %SCHEMA%.%FORMSTABLE% f + LEFT OUTER JOIN %SCHEMA%.%FORMAUTOMATIONSTABLE% fa ON fa.FormId = f.FormId + WHERE f.IsDeleted = false AND f.DepartmentId = %DID%"; + UpdateFormsToEnableQuery = @" + UPDATE Forms + SET IsActive = true + WHERE FormId = %FORMID%"; + UpdateFormsToDisableQuery = @" + UPDATE Forms + SET IsActive = false + WHERE FormId = %FORMID%"; + + #endregion Forms + + #region Voice + + DepartmentVoiceTableName = "DepartmentVoices"; + DepartmentVoiceChannelsTableName = "DepartmentVoiceChannels"; + DepartmentVoiceUsersTableName = "DepartmentVoiceUsers"; + SelectVoiceByDIdQuery = @" + SELECT dv.*, dvc.* + FROM %SCHEMA%.%DEPARTMENTVOICETABLE% dv + LEFT OUTER JOIN %SCHEMA%.%DEPARTMENTVOICECHANNELSTABLE% dvc ON dv.DepartmentVoiceId = dvc.DepartmentVoiceId + WHERE dv.DepartmentId = %DID%"; + SelectVoiceChannelsByVoiceIdQuery = @" + SELECT dvc.* + FROM %SCHEMA%.%DEPARTMENTVOICECHANNELSTABLE% dvc + WHERE dvc.DepartmentVoiceId = %VOICEID%"; + SelectVoiceUserByUserIdQuery = @" + SELECT dvu.* + FROM %SCHEMA%.%DEPARTMENTVOICEUSERSSTABLE% dvu + WHERE dvu.UserId = %USERID%"; + SelectVoiceChannelsByDIdQuery = @" + SELECT dvc.* + FROM %SCHEMA%.%DEPARTMENTVOICECHANNELSTABLE% dvc + WHERE dvc.DepartmentId = %DID%"; + + #endregion Voice + + #region Unit States + SelectUnitStatesByUnitInDateRangeQuery = @" + SELECT us.*, u.* + FROM %SCHEMA%.%UNITSTATESTABLE% us + INNER JOIN %SCHEMA%.%UNITSTABLE% u ON u.UnitId = us.UnitId + WHERE us.UnitId = %UNITID% AND us.Timestamp >= %STARTDATE% AND us.Timestamp <= %ENDDATE%"; + #endregion Unit States + + #region Workshifts + WorkshiftsTable = "Workshifts"; + WorkshiftDaysTable = "WorkshiftDays"; + WorkshiftEntitiesTable = "WorkshiftEntities"; + WorkshiftFillsTable = "WorkshiftFills"; + SelectAllWorkshiftsAndDaysByDidQuery = @" + SELECT ws.*, wsd.* + FROM %SCHEMA%.%WORKSHIFTSTABLE% ws + LEFT OUTER JOIN %SCHEMA%.%WORKSHIFTDAYSTABLE% wsd ON ws.WorkshiftId = wsd.WorkshiftId + WHERE ws.DepartmentId = %DID%"; + SelectWorkshiftByIdQuery = @" + SELECT ws.*, wsd.* + FROM %SCHEMA%.%WORKSHIFTSTABLE% ws + LEFT OUTER JOIN %SCHEMA%.%WORKSHIFTDAYSTABLE% wsd ON ws.WorkshiftId = wsd.WorkshiftId + WHERE ws.WorkshiftId = %ID%"; + SelectWorkshiftEntitiesByWorkshiftIdQuery = @" + SELECT * + FROM %SCHEMA%.%WORKSHIFTENTITIESTABLE% + WHERE WorkshiftId = %ID%"; + SelectWorkshiftFillsByWorkshiftIdQuery = @" + SELECT * + FROM %SCHEMA%.%WORKSHIFTFILLSTABLE% + WHERE WorkshiftId = %ID%"; + #endregion Workshifts + + #region CallReferences + CallReferencesTable = "CallReferences"; + SelectAllCallReferencesBySourceCallIdQuery = @" + SELECT cr.*, c.* + FROM %SCHEMA%.%CALLREFERENCESTABLE% cr + INNER JOIN %SCHEMA%.%CALLSTABLE% c ON cr.TargetCallId = c.CallId + WHERE cr.SourceCallId = %CALLID%"; + SelectAllCallReferencesByTargetCallIdQuery = @" + SELECT cr.*, c.* + FROM %SCHEMA%.%CALLREFERENCESTABLE% cr + INNER JOIN %SCHEMA%.%CALLSTABLE% c ON cr.SourceCallId = c.CallId + WHERE cr.TargetCallId = %CALLID%"; + #endregion CallReferences + + #region Scheduled Tasks + + ScheduledTasksTable = "ScheduledTasks"; + SelectAllUpcomingOrRecurringReportTasksQuery = @" + SELECT st.*, d.TimeZone as DepartmentTimeZone, u.Email as UserEmailAddress + FROM %SCHEMA%.%SCHEDULEDTASKSTABLE% st + INNER JOIN %SCHEMA%.%DEPARTMENTSTABLE% d ON st.DepartmentId = d.DepartmentId + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON st.UserId = u.Id + WHERE st.Active = true AND st.TaskType = 3 AND (st.SpecifcDate IS NULL OR st.SpecifcDate > %DATETIME%) AND st.DepartmentId != 0 + "; + + #endregion Scheduled Tasks + } + } +} diff --git a/Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConnectionProvider.cs b/Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConnectionProvider.cs new file mode 100644 index 00000000..ff9e7dd4 --- /dev/null +++ b/Repositories/Resgrid.Repositories.DataRepository/Servers/PostgreSql/PostgreSqlConnectionProvider.cs @@ -0,0 +1,14 @@ +using Npgsql; +using Resgrid.Model.Repositories.Connection; +using System.Data.Common; + +namespace Resgrid.Repositories.DataRepository.Servers.PostgreSql +{ + public class PostgreSqlConnectionProvider : IConnectionProvider + { + public DbConnection Create() + { + return new NpgsqlConnection(Config.DataConfig.CoreConnectionString); //+ ";Client Encoding=windows-1252;Encoding=windows-1252"); + } + } +} diff --git a/Repositories/Resgrid.Repositories.DataRepository/Servers/SqlServer/SqlServerConfiguration.cs b/Repositories/Resgrid.Repositories.DataRepository/Servers/SqlServer/SqlServerConfiguration.cs index 5747fd3b..8dde0756 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/Servers/SqlServer/SqlServerConfiguration.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/Servers/SqlServer/SqlServerConfiguration.cs @@ -156,20 +156,20 @@ public SqlServerConfiguration() DepartmentSettingsTable = "DepartmentSettings"; SelectDepartmentSettingByDepartmentIdTypeQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE [DepartmentId] = %DID% AND SettingType = %SETTINGTYPE%"; - SelectDepartmentSettingByTypeUserIdQuery = @"SELECT ds.* FROM [DepartmentSettings] ds - INNER JOIN [DepartmentMembers] dm ON ds.DepartmentId = dm.DepartmentId + SelectDepartmentSettingByTypeUserIdQuery = @"SELECT ds.* FROM %SCHEMA%.%DEPARTMENTSETTINGSTABLE% ds + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON ds.DepartmentId = dm.DepartmentId WHERE dm.UserId = %USERID% AND ds.SettingType = %SETTINGTYPE%"; SelectDepartmentSettingBySettingAndTypeQuery = @"SELECT ds.* FROM %SCHEMA%.%TABLENAME% ds WHERE ds.Setting = %SETTING% AND ds.SettingType = %SETTINGTYPE%"; SelectAllDepartmentManagerInfoQuery = @"SELECT d.DepartmentId, d.Name, up.FirstName, up.LastName, u.Email - FROM [Departments] d - INNER JOIN [AspNetUsers] u ON u.Id = d.ManagingUserId - LEFT OUTER JOIN [UserProfiles] up ON up.UserId = d.ManagingUserId"; + FROM %SCHEMA%.%DEPARTMENTSTABLE% d + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = d.ManagingUserId + LEFT OUTER JOIN UserProfiles up ON up.UserId = d.ManagingUserId"; SelectDepartmentManagerInfoByEmailQuery = @"SELECT d.DepartmentId, d.Name, up.FirstName, up.LastName, u.Email - FROM [Departments] d - INNER JOIN [AspNetUsers] u ON u.Id = d.ManagingUserId - LEFT OUTER JOIN [UserProfiles] up ON up.UserId = d.ManagingUserId + FROM %SCHEMA%.%DEPARTMENTSTABLE% d + INNER JOIN %SCHEMA%.%ASPNETUSERSTABLE% u ON u.Id = d.ManagingUserId + LEFT OUTER JOIN %SCHEMA%.%USERPROFILESTABLE% up ON up.UserId = d.ManagingUserId WHERE u.Email = %EMAILADDRESS%"; #endregion Department Settings @@ -291,23 +291,23 @@ FROM AspNetUsers u SelectRoleByDidAndNameQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE [DepartmentId] = %DID% AND [Name] = %NAME%"; SelectRolesByDidAndUserQuery = @" - SELECT * FROM [PersonnelRoles] pr - INNER JOIN [PersonnelRoleUsers] pru ON pr.[PersonnelRoleId] = pru.[PersonnelRoleId] - WHERE pru.[UserId] = %USERID% AND pr.[DepartmentId] = %DID%"; + SELECT * FROM %SCHEMA%.%PERSONNELROLESTABLE% pr + INNER JOIN %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru ON pr.PersonnelRoleId = pru.PersonnelRoleId + WHERE pru.UserId = %USERID% AND pr.DepartmentId = %DID%"; //SelectRoleUsersByRoleQuery = "SELECT * FROM %SCHEMA%.%TABLENAME% WHERE [PersonnelRoleId] = %ROLEID%"; SelectRoleUsersByRoleQuery = @" - SELECT * FROM [PersonnelRoleUsers] pru - INNER JOIN [dbo].DepartmentMembers dm ON dm.UserId = pru.UserId AND dm.[DepartmentId] = pru.[DepartmentId] - WHERE pru.[PersonnelRoleId] = %ROLEID% AND dm.[IsDisabled] = 0 AND dm.[IsDeleted] = 0"; + SELECT * FROM %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.UserId = pru.UserId AND dm.DepartmentId = pru.DepartmentId + WHERE pru.PersonnelRoleId = %ROLEID% AND dm.IsDisabled = 0 AND dm.IsDeleted = 0"; SelectRoleUsersByUserQuery = @" - SELECT * FROM [PersonnelRoleUsers] pru - INNER JOIN [PersonnelRoles] pr ON pru.[PersonnelRoleId] = pr.[PersonnelRoleId] - WHERE pru.[UserId] = %USERID% AND pr.[DepartmentId] = %DID%"; + SELECT * FROM %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru + INNER JOIN %SCHEMA%.%PERSONNELROLESTABLE% pr ON pru.PersonnelRoleId = pr.PersonnelRoleId + WHERE pru.UserId = %USERID% AND pr.DepartmentId = %DID%"; SelectRoleUsersByDidQuery = @" - SELECT * FROM [PersonnelRoleUsers] pru - INNER JOIN [PersonnelRoles] pr ON pru.[PersonnelRoleId] = pr.[PersonnelRoleId] - WHERE pr.[DepartmentId] = %DID%"; + SELECT * FROM %SCHEMA%.%PERSONNELROLEUSERSTABLE% pru + INNER JOIN %SCHEMA%.%PERSONNELROLESTABLE% pr ON pru.PersonnelRoleId = pr.PersonnelRoleId + WHERE pr.DepartmentId = %DID%"; SelectRolesByDidQuery = @" SELECT pr.*, pru.* FROM %SCHEMA%.%ROLESTABLE% pr @@ -1101,10 +1101,10 @@ SELECT DISTINCT YEAR(c.LoggedOn) SelectGroupMembersByGroupIdQuery = @" SELECT dgm.* - FROM [dbo].DepartmentGroupMembers dgm - INNER JOIN [dbo].DepartmentGroups dg ON dg.[DepartmentGroupId] = dgm.[DepartmentGroupId] - INNER JOIN [dbo].DepartmentMembers dm ON dm.UserId = dgm.UserId AND dm.[DepartmentId] = dg.[DepartmentId] - WHERE dgm.[DepartmentGroupId] = %GROUPID% AND dm.[IsDisabled] = 0 AND dm.[IsDeleted] = 0"; + FROM %SCHEMA%.%GROUPMEMBERSSTABLE% dgm + INNER JOIN %SCHEMA%.%GROUPSTABLE% dg ON dg.DepartmentGroupId = dgm.DepartmentGroupId + INNER JOIN %SCHEMA%.%DEPARTMENTMEMBERSTABLE% dm ON dm.UserId = dgm.UserId AND dm.DepartmentId = dg.DepartmentId + WHERE dgm.DepartmentGroupId = %GROUPID% AND dm.IsDisabled = 0 AND dm.IsDeleted = 0"; SelectGroupMembersByUserDidQuery = @" SELECT dgm.*, dg.* diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftDaysRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftDaysRepository.cs index f43bf80a..300432ae 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftDaysRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftDaysRepository.cs @@ -36,7 +36,7 @@ public async Task> GetAllShiftDaysByShiftIdAsync(int shift { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); var query = _queryFactory.GetQuery(); @@ -77,7 +77,7 @@ public async Task GetShiftDayByIdAsync(int shiftDayId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftDayId", shiftDayId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupAssignmentsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupAssignmentsRepository.cs index 9317ae35..419d67c6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupAssignmentsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupAssignmentsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetShiftAssignmentsByGroupI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftGroupId", shiftGroupId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupRolesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupRolesRepository.cs index 53e38068..d3f8d2da 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupRolesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupRolesRepository.cs @@ -35,7 +35,7 @@ public async Task> GetShiftGroupRolesByGroupIdAsync( { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftGroupId", shiftGroupId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupsRepository.cs index ac787630..a1e75476 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftGroupsRepository.cs @@ -36,7 +36,7 @@ public async Task> GetShiftGroupsByGroupIdAsync(int depa { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", departmentGroupId); var query = _queryFactory.GetQuery(); @@ -87,7 +87,7 @@ public async Task> GetShiftGroupsByShiftIdAsync(int shif { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftPersonRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftPersonRepository.cs index 14e431c4..3b400485 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftPersonRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftPersonRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllShiftPersonsByShiftIdAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupRepository.cs index c1ad8cd8..885980a8 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllShiftSignupsByShiftIdAsync(int { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); var query = _queryFactory.GetQuery(); @@ -76,7 +76,7 @@ public async Task> GetAllShiftSignupsByShiftIdAndDateAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); dynamicParameters.Add("ShiftDayDate", shiftDayDate); @@ -118,7 +118,7 @@ public async Task> GetAllShiftSignupsByGroupIdAndDateAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", departmentGroupId); dynamicParameters.Add("ShiftDayDate", shiftDayDate); @@ -160,7 +160,7 @@ public async Task> GetAllShiftSignupsByUserIdAsync(stri { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeRepository.cs index 862a5ce7..f3ee4e69 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeRepository.cs @@ -36,7 +36,7 @@ public async Task GetShiftSignupTradeBySourceShiftSignupIdAsyn { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftSignupId", shiftSignupId); var query = _queryFactory.GetQuery(); @@ -84,7 +84,7 @@ public async Task GetShiftSignupTradeByTargetShiftSignupIdAsyn { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftSignupId", shiftSignupId); var query = _queryFactory.GetQuery(); @@ -132,7 +132,7 @@ public async Task GetShiftSignupTradeByUserIdAsync(int shiftSi { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftSignupId", shiftSignupId); var query = _queryFactory.GetQuery(); @@ -180,7 +180,7 @@ public async Task> GetAllOpenTradeRequestsByUserId { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -221,7 +221,7 @@ public async Task> GetTradeRequestsAndSourceShifts { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeUserRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeUserRepository.cs index b062ac58..61e1b4d6 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeUserRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftSignupTradeUserRepository.cs @@ -36,7 +36,7 @@ public async Task> GetShiftSignupTradeUsersByT { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftTradeId", shiftTradeId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftStaffingRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftStaffingRepository.cs index 64ff76de..e546d575 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftStaffingRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftStaffingRepository.cs @@ -36,7 +36,7 @@ public async Task GetShiftStaffingByShiftDayAsync(int shiftId, Da { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); dynamicParameters.Add("ShiftDay", shiftDay); diff --git a/Repositories/Resgrid.Repositories.DataRepository/ShiftsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/ShiftsRepository.cs index 646111ae..902342e4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/ShiftsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/ShiftsRepository.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Dapper; using Newtonsoft.Json; +using Resgrid.Config; using Resgrid.Framework; using Resgrid.Model; using Resgrid.Model.Repositories; @@ -38,10 +39,11 @@ public async Task GetShiftAndDaysByShiftIdAsync(int shiftId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("ShiftId", shiftId); - dynamicParameters.Add("JsonResult", null, DbType.String, - ParameterDirection.Output, int.MaxValue); + + if (DataConfig.DatabaseType == DatabaseTypes.SqlServer) + dynamicParameters.Add("JsonResult", null, DbType.String, ParameterDirection.Output, int.MaxValue); var query = _queryFactory.GetQuery(); @@ -87,51 +89,6 @@ public async Task GetShiftAndDaysByShiftIdAsync(int shiftId) return null; } - - //try - //{ - // var selectFunction = new Func>(async x => - // { - // var dynamicParameters = new DynamicParameters(); - // dynamicParameters.Add("ShiftId", shiftId); - - // var query = _queryFactory.GetQuery(); - - // var dictionary = new Dictionary(); - // var result = await x.QueryAsync(sql: query, - // param: dynamicParameters, - // transaction: _unitOfWork.Transaction, - // map: ShiftDayMapping(dictionary), - // splitOn: "ShiftDayId"); - - // if (dictionary.Count > 0) - // return dictionary.Select(y => y.Value).FirstOrDefault(); - - // return result.FirstOrDefault(); - // }); - - // DbConnection conn = null; - // if (_unitOfWork?.Connection == null) - // { - // using (conn = _connectionProvider.Create()) - // { - // await conn.OpenAsync(); - - // return await selectFunction(conn); - // } - // } - // else - // { - // conn = _unitOfWork.CreateOrGetConnection(); - // return await selectFunction(conn); - // } - //} - //catch (Exception ex) - //{ - // Logging.LogException(ex); - - // return null; - //} } public async Task> GetShiftAndDaysByDepartmentIdAsync(int departmentId) @@ -140,10 +97,11 @@ public async Task> GetShiftAndDaysByDepartmentIdAsync(int dep { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); - dynamicParameters.Add("JsonResult", null, DbType.String, - ParameterDirection.Output, int.MaxValue); + + if (DataConfig.DatabaseType == DatabaseTypes.SqlServer) + dynamicParameters.Add("JsonResult", null, DbType.String, ParameterDirection.Output, int.MaxValue); var query = _queryFactory.GetQuery(); @@ -185,51 +143,6 @@ public async Task> GetShiftAndDaysByDepartmentIdAsync(int dep return null; } - - //try - //{ - // var selectFunction = new Func>>(async x => - // { - // var dynamicParameters = new DynamicParameters(); - // dynamicParameters.Add("DepartmentId", departmentId); - - // var query = _queryFactory.GetQuery(); - - // var dictionary = new Dictionary(); - // var result = await x.QueryAsync(sql: query, - // param: dynamicParameters, - // transaction: _unitOfWork.Transaction, - // map: ShiftDayMapping(dictionary), - // splitOn: "ShiftDayId"); - - // if (dictionary.Count > 0) - // return dictionary.Select(y => y.Value); - - // return result; - // }); - - // DbConnection conn = null; - // if (_unitOfWork?.Connection == null) - // { - // using (conn = _connectionProvider.Create()) - // { - // await conn.OpenAsync(); - - // return await selectFunction(conn); - // } - // } - // else - // { - // conn = _unitOfWork.CreateOrGetConnection(); - // return await selectFunction(conn); - // } - //} - //catch (Exception ex) - //{ - // Logging.LogException(ex); - - // return null; - //} } public async Task> GetAllShiftAndDaysAsync() @@ -238,9 +151,10 @@ public async Task> GetAllShiftAndDaysAsync() { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); - dynamicParameters.Add("JsonResult", null, DbType.String, - ParameterDirection.Output, int.MaxValue); + var dynamicParameters = new DynamicParametersExtension(); + + if (DataConfig.DatabaseType == DatabaseTypes.SqlServer) + dynamicParameters.Add("JsonResult", null, DbType.String, ParameterDirection.Output, int.MaxValue); var query = _queryFactory.GetQuery(); @@ -282,51 +196,6 @@ public async Task> GetAllShiftAndDaysAsync() return null; } - - //try - //{ - // var selectFunction = new Func>>(async x => - // { - // var dynamicParameters = new DynamicParameters(); - - - // var query = _queryFactory.GetQuery(); - - // var dictionary = new Dictionary(); - // var result = await x.QueryAsync(sql: query, - // param: dynamicParameters, - // transaction: _unitOfWork.Transaction, - // map: ShiftDayMapping(dictionary), - // splitOn: "ShiftDayId"); - - // if (dictionary.Count > 0) - // return dictionary.Select(y => y.Value); - - // return result; - // }); - - // DbConnection conn = null; - // if (_unitOfWork?.Connection == null) - // { - // using (conn = _connectionProvider.Create()) - // { - // await conn.OpenAsync(); - - // return await selectFunction(conn); - // } - // } - // else - // { - // conn = _unitOfWork.CreateOrGetConnection(); - // return await selectFunction(conn); - // } - //} - //catch (Exception ex) - //{ - // Logging.LogException(ex); - - // return null; - //} } private static Func ShiftDayMapping(Dictionary dictionary) diff --git a/Repositories/Resgrid.Repositories.DataRepository/TrainingAttachmentRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/TrainingAttachmentRepository.cs index 194f93c8..a5c70bf4 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/TrainingAttachmentRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/TrainingAttachmentRepository.cs @@ -35,7 +35,7 @@ public async Task> GetTrainingAttachmentsByTrain { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("TrainingId", trainingId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/TrainingQuestionRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/TrainingQuestionRepository.cs index 2700f0b0..020db434 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/TrainingQuestionRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/TrainingQuestionRepository.cs @@ -36,7 +36,7 @@ public async Task> GetTrainingQuestionsByTrainingI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("TrainingId", trainingId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/TrainingRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/TrainingRepository.cs index 6bfe40df..589dbed2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/TrainingRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/TrainingRepository.cs @@ -46,7 +46,7 @@ public async Task> GetTrainingsByDepartmentIdAsync(int dep { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -94,7 +94,7 @@ public async Task GetTrainingByTrainingIdAsync(int trainingId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("TrainingId", trainingId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/TrainingUserRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/TrainingUserRepository.cs index c770f71d..fff175ba 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/TrainingUserRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/TrainingUserRepository.cs @@ -34,7 +34,7 @@ public async Task GetTrainingUserByTrainingIdAndUserIdAsync(int tr { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("TrainingId", trainingId); dynamicParameters.Add("UserId", userId); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitActiveRolesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitActiveRolesRepository.cs index c5c8cf15..a118dae9 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitActiveRolesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitActiveRolesRepository.cs @@ -36,7 +36,7 @@ public async Task> GetActiveRolesByUnitIdAsync(int u { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); @@ -77,7 +77,7 @@ public async Task> GetAllActiveRolesForUnitsByDepart { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -120,11 +120,11 @@ public async Task DeleteActiveRolesByUnitIdAsync(int unitId, CancellationT { try { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetDeleteQuery(); - query = query.Replace("%UNITID%", unitId.ToString()); + query = query.Replace("%UNITID%", unitId.ToString(), StringComparison.InvariantCultureIgnoreCase); var result = await x.ExecuteAsync(query, dynamicParameters, _unitOfWork.Transaction); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitLocationRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitLocationRepository.cs index 87c6d9a3..25b8a31e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitLocationRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitLocationRepository.cs @@ -60,7 +60,7 @@ public async Task GetLastUnitLocationByUnitIdAsync(int unitId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); @@ -101,7 +101,7 @@ public async Task GetLastUnitLocationByUnitIdTimestampAsync(int un { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); dynamicParameters.Add("Timestamp", timestamp); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitLogsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitLogsRepository.cs index 9d9f1c8f..f1f3b5d5 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitLogsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitLogsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllLogsByUnitIdAsync(int unitId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitRolesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitRolesRepository.cs index b5b9a4e5..27cd5ab2 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitRolesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitRolesRepository.cs @@ -35,7 +35,7 @@ public async Task> GetAllRolesByUnitIdAsync(int unitId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitStateRoleRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitStateRoleRepository.cs index a530d492..3267ddb3 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitStateRoleRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitStateRoleRepository.cs @@ -35,7 +35,7 @@ public async Task> GetCurrentRolesForUnitAsync(int un { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitStatesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitStatesRepository.cs index a05ee2c4..c807627a 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitStatesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitStatesRepository.cs @@ -38,7 +38,7 @@ public async Task> GetAllStatesByUnitIdAsync(int unitId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); @@ -81,7 +81,7 @@ public async Task> GetAllUnitStatesForUnitInDateRangeAsyn { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); dynamicParameters.Add("StartDate", startDate); dynamicParameters.Add("EndDate", endDate); @@ -125,7 +125,7 @@ public async Task GetLastUnitStateByUnitIdAsync(int unitId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); var query = _queryFactory.GetQuery(); @@ -168,7 +168,7 @@ public async Task GetLastUnitStateBeforeIdAsync(int unitId, int unitS { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitId", unitId); dynamicParameters.Add("UnitStateId", unitStateId); @@ -212,7 +212,7 @@ public async Task GetUnitStateByUnitStateIdAsync(int unitStateId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UnitStateId", unitStateId); var query = _queryFactory.GetQuery(); @@ -255,7 +255,7 @@ public async Task> GetAllStatesByCallIdAsync(int callId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("CallId", callId); var query = _queryFactory.GetQuery(); @@ -298,7 +298,7 @@ public async Task> GetLatestUnitStatesForDepartmentAsync( { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitTypesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitTypesRepository.cs index bb4762ec..0c499e40 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitTypesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitTypesRepository.cs @@ -34,7 +34,7 @@ public async Task GetUnitByNameDepartmentIdAsync(int departmentId, str { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("TypeName", name); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UnitsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UnitsRepository.cs index a8892e72..4b5f347b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UnitsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UnitsRepository.cs @@ -36,7 +36,7 @@ public async Task GetUnitByNameDepartmentIdAsync(int departmentId, string { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("UnitName", name); @@ -78,7 +78,7 @@ public async Task> GetAllUnitsByGroupIdAsync(int groupId) { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("GroupId", groupId); var query = _queryFactory.GetQuery(); @@ -121,7 +121,7 @@ public async Task> GetAllUnitsByDepartmentIdAsync(int departme { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -176,7 +176,7 @@ public async Task> GetAllUnitsForTypeAsync(int departmentId, s { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("Type", type); diff --git a/Repositories/Resgrid.Repositories.DataRepository/UserProfilesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UserProfilesRepository.cs index 0b1004d5..e0dd031b 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UserProfilesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UserProfilesRepository.cs @@ -37,7 +37,7 @@ public async Task GetProfileByUserIdAsync(string userId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -81,7 +81,7 @@ public async Task GetProfileByMobileNumberAsync(string mobileNumber { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("MobileNumber", mobileNumber); var query = _queryFactory.GetQuery(); @@ -125,7 +125,7 @@ public async Task GetProfileByHomeNumberAsync(string homeNumber) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("HomeNumber", homeNumber); var query = _queryFactory.GetQuery(); @@ -169,7 +169,7 @@ public async Task> GetAllUserProfilesForDepartmentAsync { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -219,7 +219,7 @@ public async Task> GetAllUserProfilesForDepartmentIncDi { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -267,13 +267,13 @@ public async Task> GetSelectedUserProfilesAsync(List>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); var usersToQuery = String.Join(",", userIds.Select(p => $"'{p.ToString()}'").ToArray()); dynamicParameters.Add("UserIds", usersToQuery); var query = _queryFactory.GetQuery(); - query = query.Replace("@UserIds", usersToQuery); + query = query.Replace("@UserIds", usersToQuery, StringComparison.InvariantCultureIgnoreCase); var dictionary = new Dictionary(); var result = await x.QueryAsync(sql: query, diff --git a/Repositories/Resgrid.Repositories.DataRepository/UserStatesRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/UserStatesRepository.cs index 36d97f17..a32e1e9e 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/UserStatesRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/UserStatesRepository.cs @@ -35,7 +35,7 @@ public async Task> GetLatestUserStatesByDepartmentIdAsync { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("Timestamp", DateTime.UtcNow.AddMonths(-3)); @@ -77,7 +77,7 @@ public async Task> GetUserStatesByUserIdAsync(string user { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -118,7 +118,7 @@ public async Task GetLastUserStateByUserIdAsync(string userId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); var query = _queryFactory.GetQuery(); @@ -159,7 +159,7 @@ public async Task GetPreviousUserStateByUserIdAsync(string userId, in { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("UserId", userId); dynamicParameters.Add("UserStateId", userStateId); @@ -201,7 +201,7 @@ public async Task> GetAllUserStatesByDepartmentIdInRangeA { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); dynamicParameters.Add("StartDate", startDate); dynamicParameters.Add("EndDate", endDate); diff --git a/Repositories/Resgrid.Repositories.DataRepository/WorkshiftEntitysRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/WorkshiftEntitysRepository.cs index b2137fb2..05e89106 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/WorkshiftEntitysRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/WorkshiftEntitysRepository.cs @@ -35,7 +35,7 @@ public async Task> GetWorkshiftEntitiesByWorkshiftI { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("WorkshiftId", workshiftId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/WorkshiftFillsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/WorkshiftFillsRepository.cs index 2a7086c1..730344cc 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/WorkshiftFillsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/WorkshiftFillsRepository.cs @@ -35,7 +35,7 @@ public async Task> GetWorkshiftFillsByWorkshiftIdAsyn { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("WorkshiftId", workshiftId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.DataRepository/WorkshiftsRepository.cs b/Repositories/Resgrid.Repositories.DataRepository/WorkshiftsRepository.cs index 9a1ff01f..e23374ec 100644 --- a/Repositories/Resgrid.Repositories.DataRepository/WorkshiftsRepository.cs +++ b/Repositories/Resgrid.Repositories.DataRepository/WorkshiftsRepository.cs @@ -37,7 +37,7 @@ public async Task> GetAllWorkshiftAndDaysByDepartmentIdAs { var selectFunction = new Func>>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("DepartmentId", departmentId); var query = _queryFactory.GetQuery(); @@ -85,7 +85,7 @@ public async Task GetWorkshiftByIdAsync(string workshiftId) { var selectFunction = new Func>(async x => { - var dynamicParameters = new DynamicParameters(); + var dynamicParameters = new DynamicParametersExtension(); dynamicParameters.Add("WorkshiftId", workshiftId); var query = _queryFactory.GetQuery(); diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/MapLayersDocRepository.cs b/Repositories/Resgrid.Repositories.NoSqlRepository/MapLayersDocRepository.cs new file mode 100644 index 00000000..1f28c010 --- /dev/null +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/MapLayersDocRepository.cs @@ -0,0 +1,94 @@ +using Dapper; +using Newtonsoft.Json; +using Npgsql; +using Resgrid.Model; +using Resgrid.Model.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Resgrid.Repositories.NoSqlRepository +{ + public class MapLayersDocRepository: IMapLayersDocRepository + { + public async Task> GetAllMapLayersByDepartmentIdAsync(int departmentId, MapLayerTypes type) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var mapLayersData = await connection.QueryAsync($"SELECT data FROM public.maplayers ml WHERE ml.departmentid = {departmentId};"); + + if (mapLayersData != null && mapLayersData.Any()) + { + var mapLayers = mapLayersData.ToList(); + return mapLayers.Where(x => x.Type == (int)type && !x.IsDeleted).ToList(); + } + else + return new List(); + } + } + + public async Task GetByIdAsync(string id) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var mapLayersData = await connection.QueryAsync($"SELECT data FROM public.maplayers ul WHERE ul.oid = '{id}';"); + + if (mapLayersData != null) + return mapLayersData.FirstOrDefault(); + else + { + var mapLayersData2 = await connection.QueryAsync($"SELECT data FROM public.maplayers ul WHERE ul.id = {id};"); + + if (mapLayersData2 != null) + return mapLayersData2.FirstOrDefault(); + else + return null; + } + } + } + + public async Task GetByOldIdAsync(string id) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var mapLayersData = await connection.QueryAsync($"SELECT data FROM public.maplayers ul WHERE ul.oid = '{id}';"); + + if (mapLayersData != null) + return mapLayersData.FirstOrDefault(); + else + return null; + } + } + + public async Task InsertAsync(MapLayer mapLayer) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var result = await connection.ExecuteScalarAsync($"INSERT INTO public.maplayers (departmentid, data) VALUES ({mapLayer.DepartmentId}, '{JsonConvert.SerializeObject(mapLayer)}') RETURNING id;"); + mapLayer.PgId = result; + + return mapLayer; + } + } + + public async Task UpdateAsync(MapLayer mapLayer) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + + if (!string.IsNullOrWhiteSpace(mapLayer.PgId)) + await connection.ExecuteAsync($"UPDATE public.maplayers SET data = '{JsonConvert.SerializeObject(mapLayer)}' WHERE id = {mapLayer.PgId};"); + + + return mapLayer; + } + } + } +} diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/NoSqlDataModule.cs b/Repositories/Resgrid.Repositories.NoSqlRepository/NoSqlDataModule.cs index 98e4a9d6..6543844d 100644 --- a/Repositories/Resgrid.Repositories.NoSqlRepository/NoSqlDataModule.cs +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/NoSqlDataModule.cs @@ -9,6 +9,10 @@ public class NoSqlDataModule : Module protected override void Load(ContainerBuilder builder) { builder.RegisterGeneric(typeof(MongoRepository<>)).As(typeof(IMongoRepository<>)).InstancePerLifetimeScope(); + + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); } } } diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/PersonnelLocationsDocRepository.cs b/Repositories/Resgrid.Repositories.NoSqlRepository/PersonnelLocationsDocRepository.cs new file mode 100644 index 00000000..6c0712c8 --- /dev/null +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/PersonnelLocationsDocRepository.cs @@ -0,0 +1,105 @@ +using Dapper; +using Newtonsoft.Json; +using Npgsql; +using Resgrid.Model; +using Resgrid.Model.Repositories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Resgrid.Repositories.NoSqlRepository +{ + public class PersonnelLocationsDocRepository : IPersonnelLocationsDocRepository + { + public async Task> GetAllLocationsByUnitIdAsync(string userId) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var personLocationsData = await connection.QueryAsync($"SELECT data FROM public.personnellocations ul WHERE ul.userid = '{userId}' ORDER BY timestamp DESC;"); + + if (personLocationsData != null) + return personLocationsData.ToList(); + else + return new List(); + } + } + + public async Task GetLatestLocationsByUnitIdAsync(string userId) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT data FROM public.personnellocations ul WHERE ul.userid = '{userId}' ORDER BY timestamp DESC LIMIT 1;"); + + if (unitLocationsData != null) + return unitLocationsData.FirstOrDefault(); + else + return null; + } + } + + public async Task> GetLatestLocationsByDepartmentIdAsync(int departmentId) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT DISTINCT ON (userid) data FROM public.personnellocations ul WHERE ul.departmentid = {departmentId} ORDER BY timestamp DESC;"); + + if (unitLocationsData != null) + return unitLocationsData.ToList(); + else + return new List(); + } + } + + public async Task GetByIdAsync(string id) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT data FROM public.personnellocations ul WHERE ul.oid = '{id}';"); + + if (unitLocationsData != null) + return unitLocationsData.FirstOrDefault(); + else + { + var unitLocationsData2 = await connection.QueryAsync($"SELECT data FROM public.personnellocations ul WHERE ul.id = {id};"); + + if (unitLocationsData2 != null) + return unitLocationsData2.FirstOrDefault(); + else + return null; + } + } + } + + public async Task GetByOldIdAsync(string id) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var personnelLocationsData = await connection.QueryAsync($"SELECT data FROM public.personnellocations ul WHERE ul.oid = '{id}';"); + + if (personnelLocationsData != null) + return personnelLocationsData.FirstOrDefault(); + else + return null; + } + } + + public async Task InsertAsync(PersonnelLocation location) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var result = await connection.ExecuteScalarAsync($"INSERT INTO public.personnellocations (departmentid, userid, data) VALUES ({location.DepartmentId}, '{location.UserId}', '{JsonConvert.SerializeObject(location)}') RETURNING id;"); + location.PgId = result; + + return location; + } + } + } +} diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj b/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj index 16368375..a863fc25 100644 --- a/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/Resgrid.Repositories.NoSqlRepository.csproj @@ -5,7 +5,10 @@ + + + diff --git a/Repositories/Resgrid.Repositories.NoSqlRepository/UnitLocationsDocRepository.cs b/Repositories/Resgrid.Repositories.NoSqlRepository/UnitLocationsDocRepository.cs new file mode 100644 index 00000000..dd0f887e --- /dev/null +++ b/Repositories/Resgrid.Repositories.NoSqlRepository/UnitLocationsDocRepository.cs @@ -0,0 +1,105 @@ +using Npgsql; +using Resgrid.Model; +using Dapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Resgrid.Model.Repositories; + +namespace Resgrid.Repositories.NoSqlRepository +{ + public class UnitLocationsDocRepository: IUnitLocationsDocRepository + { + public async Task> GetAllLocationsByUnitIdAsync(int unitId) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT data FROM public.unitlocations ul WHERE ul.unitid = {unitId} ORDER BY timestamp DESC;"); + + if (unitLocationsData != null) + return unitLocationsData.ToList(); + else + return new List(); + } + } + + public async Task GetLatestLocationsByUnitIdAsync(int unitId) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT data FROM public.unitlocations ul WHERE ul.unitid = {unitId} ORDER BY timestamp DESC LIMIT 1;"); + + if (unitLocationsData != null) + return unitLocationsData.FirstOrDefault(); + else + return null; + } + } + + public async Task> GetLatestLocationsByDepartmentIdAsync(int departmentId) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT DISTINCT ON (unitid) data FROM public.unitlocations ul WHERE ul.departmentid = {departmentId} ORDER BY timestamp DESC;"); + + if (unitLocationsData != null) + return unitLocationsData.ToList(); + else + return new List(); + } + } + + public async Task GetByIdAsync(string id) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT data FROM public.unitlocations ul WHERE ul.oid = '{id}';"); + + if (unitLocationsData != null) + return unitLocationsData.FirstOrDefault(); + else + { + var unitLocationsData2 = await connection.QueryAsync($"SELECT data FROM public.unitlocations ul WHERE ul.id = {id};"); + + if (unitLocationsData2 != null) + return unitLocationsData2.FirstOrDefault(); + else + return null; + } + } + } + + public async Task GetByOldIdAsync(string id) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var unitLocationsData = await connection.QueryAsync($"SELECT data FROM public.unitlocations ul WHERE ul.oid = '{id}';"); + + if (unitLocationsData != null) + return unitLocationsData.FirstOrDefault(); + else + return null; + } + } + + public async Task InsertAsync(UnitsLocation location) + { + using (var connection = new NpgsqlConnection(Config.DataConfig.DocumentConnectionString)) + { + await connection.OpenAsync(); + var result = await connection.ExecuteScalarAsync($"INSERT INTO public.unitlocations (departmentid, unitid, data) VALUES ({location.DepartmentId}, {location.UnitId}, '{JsonConvert.SerializeObject(location)}') RETURNING id;"); + location.PgId = result; + + return location; + } + } + } +} diff --git a/Resgrid.sln b/Resgrid.sln index 77ed4a81..e62ceffe 100644 --- a/Resgrid.sln +++ b/Resgrid.sln @@ -88,6 +88,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Resgrid.Localization", "Cor EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Resgrid.Providers.Messaging", "Providers\Resgrid.Providers.Messaging\Resgrid.Providers.Messaging.csproj", "{B4D75669-B70B-4B75-8AB9-0B64D0176E2B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Resgrid.Providers.MigrationsPg", "Providers\Resgrid.Providers.MigrationsPg\Resgrid.Providers.MigrationsPg.csproj", "{1345A104-2F6F-433A-BD8C-B2676C5D8473}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Support", "Support", "{89331D76-C527-479D-8F30-8033A04C625F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quidjibo.Postgres", "Workers\Support\Quidjibo.Postgres\Quidjibo.Postgres.csproj", "{744B3BB7-B5F6-4002-93E2-FC0821D41963}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Azure|Any CPU = Azure|Any CPU @@ -824,6 +830,54 @@ Global {B4D75669-B70B-4B75-8AB9-0B64D0176E2B}.Staging|Any CPU.Build.0 = Debug|Any CPU {B4D75669-B70B-4B75-8AB9-0B64D0176E2B}.Staging|x86.ActiveCfg = Debug|Any CPU {B4D75669-B70B-4B75-8AB9-0B64D0176E2B}.Staging|x86.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Azure|Any CPU.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Azure|Any CPU.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Azure|x86.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Azure|x86.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Cloud|Any CPU.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Cloud|Any CPU.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Cloud|x86.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Cloud|x86.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Debug|x86.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Debug|x86.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Docker|Any CPU.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Docker|Any CPU.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Docker|x86.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Docker|x86.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Release|Any CPU.Build.0 = Release|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Release|x86.ActiveCfg = Release|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Release|x86.Build.0 = Release|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Staging|Any CPU.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Staging|Any CPU.Build.0 = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Staging|x86.ActiveCfg = Debug|Any CPU + {1345A104-2F6F-433A-BD8C-B2676C5D8473}.Staging|x86.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Azure|Any CPU.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Azure|Any CPU.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Azure|x86.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Azure|x86.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Cloud|Any CPU.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Cloud|Any CPU.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Cloud|x86.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Cloud|x86.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Debug|Any CPU.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Debug|x86.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Debug|x86.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Docker|Any CPU.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Docker|Any CPU.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Docker|x86.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Docker|x86.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Release|Any CPU.ActiveCfg = Release|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Release|Any CPU.Build.0 = Release|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Release|x86.ActiveCfg = Release|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Release|x86.Build.0 = Release|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Staging|Any CPU.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Staging|Any CPU.Build.0 = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Staging|x86.ActiveCfg = Debug|Any CPU + {744B3BB7-B5F6-4002-93E2-FC0821D41963}.Staging|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -859,6 +913,9 @@ Global {086A3F5A-F7D3-4E38-B9CD-B422DD3A709E} = {206D5D48-99B0-4913-B1E2-4BA11D021740} {E39D63BA-5CCA-43EC-A3F9-375FA87EFE2F} = {D43D1D6B-66A9-4A57-9EA3-8DECC92FA583} {B4D75669-B70B-4B75-8AB9-0B64D0176E2B} = {F06D475C-635C-4DE4-82BA-C49A90BA8FCD} + {1345A104-2F6F-433A-BD8C-B2676C5D8473} = {F06D475C-635C-4DE4-82BA-C49A90BA8FCD} + {89331D76-C527-479D-8F30-8033A04C625F} = {DBB9862A-C008-4C3F-A9DB-320429E4A07F} + {744B3BB7-B5F6-4002-93E2-FC0821D41963} = {89331D76-C527-479D-8F30-8033A04C625F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {156116FF-243E-45E8-8717-DB72E95F56AF} diff --git a/Tools/Resgrid.Console/Args/MigrateDocsDbArgs.cs b/Tools/Resgrid.Console/Args/MigrateDocsDbArgs.cs new file mode 100644 index 00000000..242f11c9 --- /dev/null +++ b/Tools/Resgrid.Console/Args/MigrateDocsDbArgs.cs @@ -0,0 +1,7 @@ +namespace Resgrid.Console.Args +{ + public class MigrateDocsDbArgs + { + public bool MigrateDocsDb { get; set; } + } +} diff --git a/Tools/Resgrid.Console/Commands/MigrateDocsDbCommand.cs b/Tools/Resgrid.Console/Commands/MigrateDocsDbCommand.cs new file mode 100644 index 00000000..3215aed2 --- /dev/null +++ b/Tools/Resgrid.Console/Commands/MigrateDocsDbCommand.cs @@ -0,0 +1,105 @@ +using Resgrid.Console.Args; +using System; +using Consolas2.Core; +using Resgrid.Workers.Framework; +using Autofac; +using Resgrid.Model.Repositories; +using Resgrid.Model; +using Stripe.Identity; +using System.Linq; +using System.Threading.Tasks; + +namespace Resgrid.Console.Commands +{ + public class MigrateDocsDbCommand : Command + { + private readonly IConsole _console; + + public MigrateDocsDbCommand(IConsole console) + { + _console = console; + } + + public string Execute(MigrateDocsDbArgs args) + { + _console.WriteLine("Migrating Documents from Mongo to Postgres"); + _console.WriteLine("Please Wait..."); + + try + { + var mapLayersRepository = Bootstrapper.GetKernel().Resolve>(); + var unitsLocationRepository = Bootstrapper.GetKernel().Resolve>(); + var personnelLocationRepository = Bootstrapper.GetKernel().Resolve>(); + + var mapLayersDocRepository = Bootstrapper.GetKernel().Resolve(); + var unitsLocationsDocRepository = Bootstrapper.GetKernel().Resolve(); + var personnelLocationsDocRepository = Bootstrapper.GetKernel().Resolve(); + + _console.WriteLine("Migrating Map Layers..."); + + var layers = mapLayersRepository.AsQueryable().ToList(); + + if (layers != null && layers.Any()) + { + Parallel.ForEach(layers, layer => + { + var existingLayer = mapLayersDocRepository.GetByOldIdAsync(layer.Id.ToString()).Result; + + if (existingLayer == null) + { + _console.WriteLine($"Migrating Map: {layer.Id.ToString()}"); + mapLayersDocRepository.InsertAsync(layer). + ContinueWith(t => _console.WriteLine(t.Exception), + TaskContinuationOptions.OnlyOnFaulted); + } + }); + } + + var unitLocations = unitsLocationRepository.AsQueryable().ToList(); + + if (unitLocations != null && unitLocations.Any()) + { + Parallel.ForEach(unitLocations, unitLocation => + { + var existingLocation = unitsLocationsDocRepository.GetByOldIdAsync(unitLocation.Id.ToString()).Result; + + if (existingLocation == null) + { + _console.WriteLine($"Migrating Unit Location: {unitLocation.Id.ToString()}"); + unitsLocationsDocRepository.InsertAsync(unitLocation). + ContinueWith(t => _console.WriteLine(t.Exception), + TaskContinuationOptions.OnlyOnFaulted); + } + }); + } + + var personnelLocations = personnelLocationRepository.AsQueryable().ToList(); + + if (personnelLocations != null && personnelLocations.Any()) + { + Parallel.ForEach(personnelLocations, personLocation => + { + var existingLocation = personnelLocationsDocRepository.GetByOldIdAsync(personLocation.Id.ToString()).Result; + + if (existingLocation == null) + { + _console.WriteLine($"Migrating Personnel Location: {personLocation.Id.ToString()}"); + personnelLocationsDocRepository.InsertAsync(personLocation). + ContinueWith(t => _console.WriteLine(t.Exception), + TaskContinuationOptions.OnlyOnFaulted); + } + }); + } + + _console.WriteLine("Finished Migrating Documents."); + } + catch (Exception ex) + { + _console.WriteLine(ex.ToString()); + } + + + return ""; + } + } +} diff --git a/Tools/Resgrid.Console/Commands/OidcUpdateCommand.cs b/Tools/Resgrid.Console/Commands/OidcUpdateCommand.cs index a879c7c3..caf1ae9d 100644 --- a/Tools/Resgrid.Console/Commands/OidcUpdateCommand.cs +++ b/Tools/Resgrid.Console/Commands/OidcUpdateCommand.cs @@ -29,7 +29,7 @@ public string Execute(OidcUpdateArgs args) _console.WriteLine($"Using Database: {builder.InitialCatalog} on Server: {builder.DataSource}"); var oidcRepository = Bootstrapper.GetKernel().Resolve(); - bool result = oidcRepository.UpdateOidcDatabase(); + bool result = oidcRepository.UpdateOidcDatabaseAsync().Result; if (result) _console.WriteLine("Completed updating the Resgrid OIDC DB!"); diff --git a/Tools/Resgrid.Console/Properties/launchSettings.json b/Tools/Resgrid.Console/Properties/launchSettings.json index 0a37016e..00e18d7d 100644 --- a/Tools/Resgrid.Console/Properties/launchSettings.json +++ b/Tools/Resgrid.Console/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Resgrid.Console": { "commandName": "Project", - "commandLineArgs": "--SecurityRefresh" + "commandLineArgs": "--MigrateDocsDb" } } } \ No newline at end of file diff --git a/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs b/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs index 9d512f61..85504dd4 100644 --- a/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs +++ b/Web/Resgrid.Web.ServicesCore/Controllers/v4/CalendarController.cs @@ -39,7 +39,6 @@ public CalendarController(ICalendarService calendarService, IDepartmentsService } #endregion Members and Constructors - /// /// Gets the department calendar items. /// diff --git a/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/AddArchivedCall.cshtml b/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/AddArchivedCall.cshtml index a153fe60..4d789cdd 100644 --- a/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/AddArchivedCall.cshtml +++ b/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/AddArchivedCall.cshtml @@ -73,11 +73,11 @@
-
@Html.DropDownListFor(m => m.CallPriority, Model.CallPriorities, new { @style = "width: 120px;", tabindex = "2" })
+
@Html.DropDownListFor(m => m.CallPriority, Model.CallPriorities, new { @style = "width: 200px;", tabindex = "2" })
-
@Html.DropDownListFor(m => m.Call.Type, Model.CallTypes, new { @style = "width: 120px;", tabindex = "3" })
+
@Html.DropDownListFor(m => m.Call.Type, Model.CallTypes, new { @style = "width: 200px;", tabindex = "3" })
diff --git a/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/UpdateCall.cshtml b/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/UpdateCall.cshtml index 2330b360..ad455a6b 100644 --- a/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/UpdateCall.cshtml +++ b/Web/Resgrid.WebCore/Areas/User/Views/Dispatch/UpdateCall.cshtml @@ -65,11 +65,11 @@
-
@Html.DropDownListFor(m => m.CallPriority, Model.CallPriorities, new { @style = "width: 120px;", tabindex = "2" })
+
@Html.DropDownListFor(m => m.CallPriority, Model.CallPriorities, new { @style = "width: 200px;", tabindex = "2" })
-
@Html.DropDownListFor(m => m.Call.Type, Model.CallTypes, new { @style = "width: 120px;", tabindex = "3" })
+
@Html.DropDownListFor(m => m.Call.Type, Model.CallTypes, new { @style = "width: 200px;", tabindex = "3" })
diff --git a/Workers/Resgrid.Workers.Console/Program.cs b/Workers/Resgrid.Workers.Console/Program.cs index 06a4c067..9a683cc5 100644 --- a/Workers/Resgrid.Workers.Console/Program.cs +++ b/Workers/Resgrid.Workers.Console/Program.cs @@ -31,6 +31,10 @@ using Resgrid.Model.Repositories; using System.Reflection; using Sentry; +using Resgrid.Framework; +using Resgrid.Providers.MigrationsPg.Migrations; +using Quidjibo.Clients; +using Quidjibo.Postgres.Extensions; namespace Resgrid.Workers.Console { @@ -38,7 +42,6 @@ public class Program { public static IConfigurationRoot Configuration { get; private set; } - static async Task Main(string[] args) { #if DEBUG @@ -215,6 +218,8 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken) public class ScheduledJobsService : BackgroundService { private ILogger _logger; + private IQuidjiboClient Client { get; set; } + private QuidjiboBuilder Builder { get; set; } public ScheduledJobsService(ILogger logger) { @@ -240,15 +245,30 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) var container = containerBuilder.Build(); // Setup Quidjibo - var quidjiboBuilder = new QuidjiboBuilder() - .ConfigureLogging(loggerFactory) - .UseAutofac(container) - .UseAes(Encoding.ASCII.GetBytes(WorkerConfig.PayloadKey)) - .UseSqlServer(WorkerConfig.WorkerDbConnectionString) - .ConfigurePipeline(pipeline => pipeline.UseDefault()); - - // Quidjibo Client - var client = quidjiboBuilder.BuildClient(); + if (WorkerConfig.DatabaseType == DatabaseTypes.Postgres) + { + Builder = new QuidjiboBuilder() + .ConfigureLogging(loggerFactory) + .UseAutofac(container) + .UseAes(Encoding.ASCII.GetBytes(WorkerConfig.PayloadKey)) + .UsePostgres(WorkerConfig.WorkerDbConnectionString) + .ConfigurePipeline(pipeline => pipeline.UseDefault()); + + // Quidjibo Client + Client = Builder.BuildClient(); + } + else + { + Builder = new QuidjiboBuilder() + .ConfigureLogging(loggerFactory) + .UseAutofac(container) + .UseAes(Encoding.ASCII.GetBytes(WorkerConfig.PayloadKey)) + .UseSqlServer(WorkerConfig.WorkerDbConnectionString) + .ConfigurePipeline(pipeline => pipeline.UseDefault()); + + // Quidjibo Client + Client = Builder.BuildClient(); + } _logger.Log(LogLevel.Information, "Scheduler Started"); @@ -264,7 +284,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) // Scheduled Jobs _logger.Log(LogLevel.Information, "Scheduling Calendar Notifications"); - await client.ScheduleAsync("Calendar Notifications", + await Client.ScheduleAsync("Calendar Notifications", new CalendarNotificationCommand(1), Cron.MinuteIntervals(20), stoppingToken); @@ -276,61 +296,61 @@ await client.ScheduleAsync("Calendar Notifications", // cancellationToken); _logger.Log(LogLevel.Information, "Scheduling Call Pruning"); - await client.ScheduleAsync("Call Pruning", + await Client.ScheduleAsync("Call Pruning", new CallPruneCommand(3), Cron.MinuteIntervals(60), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Report Delivery"); - await client.ScheduleAsync("Report Delivery", + await Client.ScheduleAsync("Report Delivery", new ReportDeliveryTaskCommand(5), Cron.MinuteIntervals(14), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Shift Notifier"); - await client.ScheduleAsync("Shift Notifier", + await Client.ScheduleAsync("Shift Notifier", new ShiftNotiferCommand(6), Cron.MinuteIntervals(720), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Staffing Schedule"); - await client.ScheduleAsync("Staffing Schedule", + await Client.ScheduleAsync("Staffing Schedule", new Commands.StaffingScheduleCommand(7), Cron.MinuteIntervals(5), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Training Notifier"); - await client.ScheduleAsync("Training Notifier", + await Client.ScheduleAsync("Training Notifier", new TrainingNotiferCommand(9), Cron.MinuteIntervals(30), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Status Schedule"); - await client.ScheduleAsync("Status Schedule", + await Client.ScheduleAsync("Status Schedule", new Commands.StatusScheduleCommand(11), Cron.MinuteIntervals(5), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Dispatch Scheduled Calls"); - await client.ScheduleAsync("Scheduled Calls", + await Client.ScheduleAsync("Scheduled Calls", new Commands.StatusScheduleCommand(12), Cron.MinuteIntervals(5), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling OIDC Token Cleaning"); - await client.ScheduleAsync("Clean OIDC Tokens", + await Client.ScheduleAsync("Clean OIDC Tokens", new Commands.CleanOIDCCommand(13), Cron.MinuteIntervals(30), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling System SQL Queue"); - await client.ScheduleAsync("System SQL Queue", + await Client.ScheduleAsync("System SQL Queue", new Commands.SystemSqlQueueCommand(14), Cron.Daily(3, 0), stoppingToken); _logger.Log(LogLevel.Information, "Scheduling Security Refresh"); - await client.ScheduleAsync("Security Refresh", + await Client.ScheduleAsync("Security Refresh", new Commands.SecurityRefreshScheduleCommand(15), Cron.Daily(2, 0), stoppingToken); @@ -342,7 +362,7 @@ await client.ScheduleAsync("Security Refresh", // Quidjibo Server - using (var workServer = quidjiboBuilder.BuildServer()) + using (var workServer = Builder.BuildServer()) { // Start Quidjibo workServer.Start(); @@ -382,7 +402,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) using (var scope = serviceProvider.CreateScope()) { UpdateDatabase(scope.ServiceProvider); - UpdateOidcDatabase(scope.ServiceProvider); + await UpdateOidcDatabaseAsync(scope.ServiceProvider); } _logger.Log(LogLevel.Information, "Completed updating the Resgrid Database!"); @@ -410,28 +430,48 @@ private static void UpdateDatabase(IServiceProvider serviceProvider) /// /// Update the database /// - private static void UpdateOidcDatabase(IServiceProvider serviceProvider) + private static async Task UpdateOidcDatabaseAsync(IServiceProvider serviceProvider) { var oidcRepository = Bootstrapper.GetKernel().Resolve(); - bool result = oidcRepository.UpdateOidcDatabase(); + bool result = await oidcRepository.UpdateOidcDatabaseAsync(); } private static IServiceProvider CreateServices() { - return new ServiceCollection() - // Add common FluentMigrator services - .AddFluentMigratorCore() - .ConfigureRunner(rb => rb - // Add SQL Server support to FluentMigrator - .AddSqlServer() - // Set the connection string - .WithGlobalConnectionString(System.Configuration.ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString) - // Define the assembly containing the migrations - .ScanIn(typeof(M0001_InitialMigration).Assembly).For.Migrations().For.EmbeddedResources()) - // Enable logging to console in the FluentMigrator way - .AddLogging(lb => lb.AddFluentMigratorConsole()) - // Build the service provider - .BuildServiceProvider(false); + if (Config.DataConfig.DatabaseType == Config.DatabaseTypes.Postgres) + { + return new ServiceCollection() + // Add common FluentMigrator services + .AddFluentMigratorCore() + .ConfigureRunner(rb => rb + // Add SQL Server support to FluentMigrator + .AddPostgres11_0() + // Set the connection string + .WithGlobalConnectionString(Config.DataConfig.CoreConnectionString) + // Define the assembly containing the migrations + .ScanIn(typeof(M0001_InitialMigrationPg).Assembly).For.Migrations().For.EmbeddedResources()) + // Enable logging to console in the FluentMigrator way + .AddLogging(lb => lb.AddFluentMigratorConsole()) + // Build the service provider + .BuildServiceProvider(false); + } + else + { + return new ServiceCollection() + // Add common FluentMigrator services + .AddFluentMigratorCore() + .ConfigureRunner(rb => rb + // Add SQL Server support to FluentMigrator + .AddSqlServer() + // Set the connection string + .WithGlobalConnectionString(System.Configuration.ConfigurationManager.ConnectionStrings["ResgridContext"].ConnectionString) + // Define the assembly containing the migrations + .ScanIn(typeof(M0001_InitialMigration).Assembly).For.Migrations().For.EmbeddedResources()) + // Enable logging to console in the FluentMigrator way + .AddLogging(lb => lb.AddFluentMigratorConsole()) + // Build the service provider + .BuildServiceProvider(false); + } } } } diff --git a/Workers/Resgrid.Workers.Console/Properties/launchSettings.json b/Workers/Resgrid.Workers.Console/Properties/launchSettings.json index 58062c76..927ff0ca 100644 --- a/Workers/Resgrid.Workers.Console/Properties/launchSettings.json +++ b/Workers/Resgrid.Workers.Console/Properties/launchSettings.json @@ -9,9 +9,8 @@ "Docker": { "commandName": "Docker", "environmentVariables": { - "Key": "Value", - "RESGRID__DataConfig__ConnectionString": "Server=192.168.1.71;Database=Resgrid;User Id=resgrid_app;Password=resgrid123;MultipleActiveResultSets=True;" + "Key": "Value" } } } -} \ No newline at end of file +} diff --git a/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj b/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj index 630afbbf..8cc723b0 100644 --- a/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj +++ b/Workers/Resgrid.Workers.Console/Resgrid.Workers.Console.csproj @@ -51,12 +51,14 @@ + + diff --git a/Workers/Support/Quidjibo.Postgres/Configurations/PostgresQuidjiboConfiguration.cs b/Workers/Support/Quidjibo.Postgres/Configurations/PostgresQuidjiboConfiguration.cs new file mode 100644 index 00000000..7de5fe07 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Configurations/PostgresQuidjiboConfiguration.cs @@ -0,0 +1,48 @@ +// // Copyright (c) smiggleworth. All rights reserved. +// // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Quidjibo.Configurations; +using Quidjibo.Constants; + +namespace Quidjibo.Postgres.Configurations +{ + public class PostgresQuidjiboConfiguration : IQuidjiboConfiguration + { + public int PollingInterval { get; set; } = 10; + public string ConnectionString { get; set; } + + /// + /// The number of days to keep completed/faulted work items. + /// + public int DaysToKeep { get; set; } = 3; + + public int BatchSize { get; set; } = 5; + + /// + public int? WorkPollingInterval { get; set; } + + /// + public bool EnableScheduler { get; set; } = true; + + /// + public int? SchedulePollingInterval { get; set; } + + /// + public bool EnableWorker { get; set; } = true; + + /// + public bool SingleLoop { get; set; } = true; + + /// + public int LockInterval { get; set; } = 30; + + /// + public int MaxAttempts { get; set; } = 5; + + /// + public int Throttle { get; set; } = 10; + + /// + public string[] Queues { get; set; } = Default.Queues; + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlCommandExtensions.cs b/Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlCommandExtensions.cs new file mode 100644 index 00000000..a3146e9b --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlCommandExtensions.cs @@ -0,0 +1,78 @@ +// Copyright (c) smiggleworth. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Npgsql; +using NpgsqlTypes; +using Quidjibo.Models; +using Quidjibo.Postgres.Providers; +using Quidjibo.Postgres.Utils; + +namespace Quidjibo.Postgres.Extensions +{ + public static class NpgsqlCommandExtensions + { + public static async Task PrepareForSendAsync(this NpgsqlCommand cmd, WorkItem item, int delay, CancellationToken cancellationToken) + { + var createdOn = DateTime.UtcNow; + var visibleOn = createdOn.AddSeconds(delay); + var expireOn = item.ExpireOn == default(DateTime) ? visibleOn.AddDays(PostgresWorkProvider.DEFAULT_EXPIRE_DAYS) : item.ExpireOn; + +#pragma warning disable CA2100 // Review SQL queries for security vulnerabilities + cmd.CommandText = await SqlLoader.GetScript("Work.Send"); +#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities + cmd.Parameters.AddWithValue("@Id", item.Id); + cmd.Parameters.AddWithValue("@ScheduleId", item.ScheduleId); + cmd.Parameters.AddWithValue("@CorrelationId", item.CorrelationId); + cmd.Parameters.AddWithValue("@Name", item.Name); + + if (item.Worker == null) + cmd.Parameters.AddWithValue("@Worker", NpgsqlDbType.Varchar, DBNull.Value); + else + cmd.Parameters.AddWithValue("@Worker", NpgsqlDbType.Varchar, item.Worker); + + cmd.Parameters.AddWithValue("@Queue", item.Queue); + cmd.Parameters.AddWithValue("@Attempts", item.Attempts); + cmd.Parameters.AddWithValue("@CreatedOn", createdOn); + cmd.Parameters.AddWithValue("@ExpireOn", expireOn); + cmd.Parameters.AddWithValue("@VisibleOn", visibleOn); + cmd.Parameters.AddWithValue("@Status", ((int)PostgresWorkProvider.StatusFlags.New)); + cmd.Parameters.AddWithValue("@Payload", item.Payload); + + } + + public static async Task PrepareForRenewAsync(this NpgsqlCommand cmd, WorkItem item, DateTime lockExpireOn, CancellationToken cancellationToken) + { +#pragma warning disable CA2100 // Review SQL queries for security vulnerabilities + cmd.CommandText = await SqlLoader.GetScript("Work.Renew"); +#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities + cmd.Parameters.AddWithValue("@Id", item.Id); + cmd.Parameters.AddWithValue("@VisibleOn", lockExpireOn); + } + + public static async Task PrepareForCompleteAsync(this NpgsqlCommand cmd, WorkItem item, CancellationToken cancellationToken) + { +#pragma warning disable CA2100 // Review SQL queries for security vulnerabilities + cmd.CommandText = await SqlLoader.GetScript("Work.Complete"); +#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities + cmd.Parameters.AddWithValue("@Id", item.Id); + cmd.Parameters.AddWithValue("@Complete", ((int)PostgresWorkProvider.StatusFlags.Complete)); + } + + public static async Task PrepareForFaultAsync(this NpgsqlCommand cmd, WorkItem item, int visibilityTimeout, CancellationToken cancellationToken) + { + var faultedOn = DateTime.UtcNow; + +#pragma warning disable CA2100 // Review SQL queries for security vulnerabilities + cmd.CommandText = await SqlLoader.GetScript("Work.Fault"); +#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities + cmd.Parameters.AddWithValue("@Id", item.Id); + cmd.Parameters.AddWithValue("@VisibleOn", faultedOn.AddSeconds(Math.Max(visibilityTimeout, 30))); + cmd.Parameters.AddWithValue("@Faulted", ((int)PostgresWorkProvider.StatusFlags.Faulted)); + } + + } + +} diff --git a/Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlParameterCollectionExtensions.cs b/Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlParameterCollectionExtensions.cs new file mode 100644 index 00000000..b6e9e88a --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Extensions/NpgsqlParameterCollectionExtensions.cs @@ -0,0 +1,13 @@ +using Npgsql; +using System; + +namespace Quidjibo.Postgres.Extensions +{ + public static class NpgsqlParameterCollectionExtensions + { + public static NpgsqlParameter AddParameter(this NpgsqlCommand cmd, string name, object value) + { + return cmd.Parameters.AddWithValue(name, value ?? DBNull.Value); + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Extensions/QuidjiboBuilderExtensions.cs b/Workers/Support/Quidjibo.Postgres/Extensions/QuidjiboBuilderExtensions.cs new file mode 100644 index 00000000..a3961800 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Extensions/QuidjiboBuilderExtensions.cs @@ -0,0 +1,95 @@ +using System; +using Quidjibo.Constants; +using Quidjibo.Postgres.Configurations; +using Quidjibo.Postgres.Factories; + +namespace Quidjibo.Postgres.Extensions +{ + public static class QuidjiboBuilderExtensions + { + /// + /// Use Sql Server for Work, Progress, an Scheduled Jobs + /// + /// + /// + /// + public static QuidjiboBuilder UsePostgres(this QuidjiboBuilder builder, Action sqlServerQuidjiboConfiguration) + { + var config = new PostgresQuidjiboConfiguration(); + sqlServerQuidjiboConfiguration(config); + return builder.UsePostgres(config); + } + + /// + /// Use Sql Server for Work, Progress, and Scheduled Jobs + /// + /// + /// + /// + public static QuidjiboBuilder UsePostgres(this QuidjiboBuilder builder, PostgresQuidjiboConfiguration sqlServerQuidjiboConfiguration) + { + return builder.Configure(sqlServerQuidjiboConfiguration) + .ConfigureWorkProviderFactory(new PostgresWorkProviderFactory(builder.LoggerFactory, sqlServerQuidjiboConfiguration)) + .ConfigureProgressProviderFactory(new PostgresProgressProviderFactory(builder.LoggerFactory, sqlServerQuidjiboConfiguration.ConnectionString)) + .ConfigureScheduleProviderFactory(new PostgresScheduleProviderFactory(builder.LoggerFactory, sqlServerQuidjiboConfiguration.ConnectionString)); + } + + /// + /// Use Sql Server for Work, Progress, and Scheduled Jobs + /// + /// + /// + /// + /// + public static QuidjiboBuilder UsePostgres(this QuidjiboBuilder builder, string connectionString, params string[] queues) + { + if (queues == null || queues.Length == 0) + { + queues = Default.Queues; + } + + var config = new PostgresQuidjiboConfiguration + { + ConnectionString = connectionString, + Queues = queues + }; + return builder.Configure(config) + .ConfigureWorkProviderFactory(new PostgresWorkProviderFactory(builder.LoggerFactory, config)) + .ConfigureProgressProviderFactory(new PostgresProgressProviderFactory(builder.LoggerFactory, connectionString)) + .ConfigureScheduleProviderFactory(new PostgresScheduleProviderFactory(builder.LoggerFactory, connectionString)); + } + + /// + /// Use Sql Server For Work + /// + /// + /// + /// + public static QuidjiboBuilder UsePostgresForWork(this QuidjiboBuilder builder, PostgresQuidjiboConfiguration sqlServerQuidjiboConfiguration) + { + return builder.ConfigureWorkProviderFactory(new PostgresWorkProviderFactory(builder.LoggerFactory, sqlServerQuidjiboConfiguration)); + } + + /// + /// Use Sql Server For Progress + /// + /// + /// + /// + public static QuidjiboBuilder UsePostgresForProgress(this QuidjiboBuilder builder, string connectionString) + { + return builder.ConfigureProgressProviderFactory(new PostgresProgressProviderFactory(builder.LoggerFactory, connectionString)); + } + + /// + /// Use Sql Server For Scheduled Jobs + /// + /// + /// + /// + public static QuidjiboBuilder UsePostgresForSchedule(this QuidjiboBuilder builder, string connectionString) + { + return builder.ConfigureScheduleProviderFactory(new PostgresScheduleProviderFactory(builder.LoggerFactory, connectionString)); + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Factories/PostgresProgressProviderFactory.cs b/Workers/Support/Quidjibo.Postgres/Factories/PostgresProgressProviderFactory.cs new file mode 100644 index 00000000..cc6af12b --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Factories/PostgresProgressProviderFactory.cs @@ -0,0 +1,59 @@ +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quidjibo.Factories; +using Quidjibo.Providers; +using Quidjibo.Postgres.Providers; +using Quidjibo.Postgres.Utils; + +namespace Quidjibo.Postgres.Factories +{ + public class PostgresProgressProviderFactory : IProgressProviderFactory + { + private static readonly SemaphoreSlim SyncLock = new SemaphoreSlim(1, 1); + private readonly string _connectionString; + + private readonly ILoggerFactory _loggerFactory; + private IProgressProvider _provider; + + public PostgresProgressProviderFactory( + ILoggerFactory loggerFactory, + string connectionString) + { + _loggerFactory = loggerFactory; + _connectionString = connectionString; + } + + public Task CreateAsync(string queues, CancellationToken cancellationToken = default(CancellationToken)) + { + return CreateAsync(queues.Split(','), cancellationToken); + } + + public async Task CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) + { + if (_provider != null) + { + return _provider; + } + + try + { + await SyncLock.WaitAsync(cancellationToken); + await PostgresRunner.ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Progress.Setup"); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, _connectionString, false, cancellationToken); + + _provider = new PostgresProgressProvider( + _loggerFactory.CreateLogger(), + _connectionString); + return _provider; + } + finally + { + SyncLock.Release(); + } + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Factories/PostgresScheduleProviderFactory.cs b/Workers/Support/Quidjibo.Postgres/Factories/PostgresScheduleProviderFactory.cs new file mode 100644 index 00000000..6ac56412 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Factories/PostgresScheduleProviderFactory.cs @@ -0,0 +1,54 @@ +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quidjibo.Factories; +using Quidjibo.Providers; +using Quidjibo.Postgres.Providers; +using Quidjibo.Postgres.Utils; + +namespace Quidjibo.Postgres.Factories +{ + public class PostgresScheduleProviderFactory : IScheduleProviderFactory + { + private static readonly SemaphoreSlim SyncLock = new SemaphoreSlim(1, 1); + private readonly string _connectionString; + + private readonly ILoggerFactory _loggerFactory; + + public PostgresScheduleProviderFactory( + ILoggerFactory loggerFactory, + string connectionString) + { + _loggerFactory = loggerFactory; + _connectionString = connectionString; + } + + public async Task CreateAsync(string queues, CancellationToken cancellationToken = default(CancellationToken)) + { + return await CreateAsync(queues.Split(','), cancellationToken); + } + + public async Task CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) + { + try + { + await SyncLock.WaitAsync(cancellationToken); + await PostgresRunner.ExecuteAsync(async cmd => + { + var schemaSetup = await SqlLoader.GetScript("Schema.Setup"); + var scheduleSetup = await SqlLoader.GetScript("Schedule.Setup"); + cmd.CommandText = $"{schemaSetup};\r\n{scheduleSetup}"; + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, _connectionString, false, cancellationToken); + + return await Task.FromResult(new PostgresScheduleProvider( + _loggerFactory.CreateLogger(), + _connectionString, queues)); + } + finally + { + SyncLock.Release(); + } + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Factories/PostgresWorkProviderFactory.cs b/Workers/Support/Quidjibo.Postgres/Factories/PostgresWorkProviderFactory.cs new file mode 100644 index 00000000..824db74b --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Factories/PostgresWorkProviderFactory.cs @@ -0,0 +1,63 @@ +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quidjibo.Factories; +using Quidjibo.Providers; +using Quidjibo.Postgres.Configurations; +using Quidjibo.Postgres.Providers; +using Quidjibo.Postgres.Utils; + +namespace Quidjibo.Postgres.Factories +{ + public class PostgresWorkProviderFactory : IWorkProviderFactory + { + private static readonly SemaphoreSlim SyncLock = new SemaphoreSlim(1, 1); + private readonly ILoggerFactory _loggerFactory; + private readonly PostgresQuidjiboConfiguration _sqlServerQuidjiboConfiguration; + private bool _initialized; + + public PostgresWorkProviderFactory( + ILoggerFactory loggerFactory, + PostgresQuidjiboConfiguration sqlServerQuidjiboConfiguration) + { + _loggerFactory = loggerFactory; + _sqlServerQuidjiboConfiguration = sqlServerQuidjiboConfiguration; + } + + public Task CreateAsync(string queues, CancellationToken cancellationToken = default(CancellationToken)) + { + return CreateAsync(queues.Split(','), cancellationToken); + } + + public async Task CreateAsync(string[] queues, CancellationToken cancellationToken = default(CancellationToken)) + { + try + { + await SyncLock.WaitAsync(cancellationToken); + if (!_initialized) + { + await PostgresRunner.ExecuteAsync(async cmd => + { + var schemaSetup = await SqlLoader.GetScript("Schema.Setup"); + var workSetup = await SqlLoader.GetScript("Work.Setup"); + cmd.CommandText = $"{schemaSetup};\r\n{workSetup}"; + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, _sqlServerQuidjiboConfiguration.ConnectionString, false, cancellationToken); + _initialized = true; + } + + return new PostgresWorkProvider( + _loggerFactory.CreateLogger(), + _sqlServerQuidjiboConfiguration.ConnectionString, + queues, + _sqlServerQuidjiboConfiguration.LockInterval, + _sqlServerQuidjiboConfiguration.BatchSize, + _sqlServerQuidjiboConfiguration.DaysToKeep); + } + finally + { + SyncLock.Release(); + } + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Providers/PostgresProgressProvider.cs b/Workers/Support/Quidjibo.Postgres/Providers/PostgresProgressProvider.cs new file mode 100644 index 00000000..c5c44167 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Providers/PostgresProgressProvider.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quidjibo.Models; +using Quidjibo.Providers; +using Quidjibo.Postgres.Extensions; +using Quidjibo.Postgres.Utils; +using Npgsql; + +namespace Quidjibo.Postgres.Providers +{ + public class PostgresProgressProvider : IProgressProvider + { + private readonly string _connectionString; + private readonly ILogger _logger; + + public PostgresProgressProvider( + ILogger logger, + string connectionString) + { + _logger = logger; + _connectionString = connectionString; + } + + public async Task ReportAsync(ProgressItem item, CancellationToken cancellationToken) + { + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Progress.Create"); + cmd.AddParameter("@Id", item.Id); + cmd.AddParameter("@WorkId", item.WorkId); + cmd.AddParameter("@CorrelationId", item.CorrelationId); + cmd.AddParameter("@Name", item.Name); + cmd.AddParameter("@Queue", item.Queue); + cmd.AddParameter("@RecordedOn", item.RecordedOn); + cmd.AddParameter("@Value", item.Value); + cmd.AddParameter("@Note", item.Note); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + await Task.CompletedTask; + } + + public async Task> LoadByCorrelationIdAsync(Guid correlationId, CancellationToken cancellationToken) + { + var items = new List(); + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Progress.LoadByCorrelationId"); + cmd.AddParameter("@CorrelationId", correlationId); + using (var rdr = await cmd.ExecuteReaderAsync(cancellationToken)) + { + while (await rdr.ReadAsync(cancellationToken)) + { + var workItem = new ProgressItem + { + CorrelationId = rdr.Map(nameof(ProgressItem.CorrelationId).ToLowerInvariant()), + Id = rdr.Map(nameof(ProgressItem.Id).ToLowerInvariant()), + Name = rdr.Map(nameof(ProgressItem.Name).ToLowerInvariant()), + Note = rdr.Map(nameof(ProgressItem.Note).ToLowerInvariant()), + Queue = rdr.Map(nameof(ProgressItem.Queue).ToLowerInvariant()), + RecordedOn = rdr.Map(nameof(ProgressItem.RecordedOn).ToLowerInvariant()), + Value = rdr.Map(nameof(ProgressItem.Value).ToLowerInvariant()), + WorkId = rdr.Map(nameof(ProgressItem.WorkId).ToLowerInvariant()) + }; + items.Add(workItem); + } + } + }, cancellationToken); + return items; + } + + private Task ExecuteAsync(Func func, CancellationToken cancellationToken) + { + return PostgresRunner.ExecuteAsync(func, _connectionString, true, cancellationToken); + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Providers/PostgresScheduleProvider.cs b/Workers/Support/Quidjibo.Postgres/Providers/PostgresScheduleProvider.cs new file mode 100644 index 00000000..0f69311a --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Providers/PostgresScheduleProvider.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quidjibo.Models; +using Quidjibo.Providers; +using Quidjibo.Postgres.Extensions; +using Quidjibo.Postgres.Utils; +using Npgsql; + +namespace Quidjibo.Postgres.Providers +{ + public class PostgresScheduleProvider : IScheduleProvider + { + private readonly string _connectionString; + private readonly ILogger _logger; + private readonly string[] _queues; + + private string _receiveSql; + + public PostgresScheduleProvider( + ILogger logger, + string connectionString, + string[] queues) + { + _logger = logger; + _connectionString = connectionString; + _queues = queues; + } + + public async Task> ReceiveAsync(CancellationToken cancellationToken = default(CancellationToken)) + { + var receiveOn = DateTime.UtcNow; + + if (_receiveSql == null) + { + _receiveSql = await SqlLoader.GetScript("Schedule.Receive"); + if (_queues.Length > 0) + { + _receiveSql = _receiveSql.Replace("@Queue1", + string.Join(",", _queues.Select((x, i) => $"@Queue{i}"))); + } + + _receiveSql = _receiveSql.Replace("@ReceiveOn", $"'{receiveOn.ToString()}'"); + _receiveSql = _receiveSql.Replace("@VisibleOn", $"'{receiveOn.ToString()}'"); + } + + var items = new List(100); + await ExecuteAsync(async cmd => + { + cmd.CommandText = _receiveSql; + cmd.AddParameter("@Take", 100); + //cmd.AddParameter("@ReceiveOn", receiveOn); + //cmd.AddParameter("@VisibleOn", receiveOn); + + // dynamic parameters + _queues.Select((q, i) => cmd.Parameters.AddWithValue($"@Queue{i}", q)).ToList(); + using (var rdr = await cmd.ExecuteReaderAsync(cancellationToken)) + { + while (await rdr.ReadAsync(cancellationToken)) + { + var item = MapScheduleItem(rdr); + items.Add(item); + } + } + }, cancellationToken); + return items; + } + + public async Task CompleteAsync(ScheduleItem item, CancellationToken cancellationToken = default(CancellationToken)) + { + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Schedule.Complete"); + cmd.AddParameter("@Id", item.Id); + cmd.AddParameter("@EnqueueOn", item.EnqueueOn); + cmd.AddParameter("@EnqueuedOn", item.EnqueuedOn); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + } + + public async Task CreateAsync(ScheduleItem item, CancellationToken cancellationToken = default(CancellationToken)) + { + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Schedule.Create"); + cmd.AddParameter("@Id", item.Id); + cmd.AddParameter("@Name", item.Name); + cmd.AddParameter("@Queue", item.Queue); + cmd.AddParameter("@CronExpression", item.CronExpression); + cmd.AddParameter("@CreatedOn", item.CreatedOn); + cmd.AddParameter("@EnqueuedOn", item.EnqueuedOn); + cmd.AddParameter("@EnqueueOn", item.EnqueueOn); + cmd.AddParameter("@VisibleOn", item.VisibleOn); + cmd.AddParameter("@Payload", item.Payload); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + } + + public async Task LoadByNameAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) + { + var item = default(ScheduleItem); + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Schedule.LoadByName"); + cmd.AddParameter("@Name", name); + using (var rdr = await cmd.ExecuteReaderAsync(cancellationToken)) + { + if (await rdr.ReadAsync(cancellationToken)) + { + item = MapScheduleItem(rdr); + } + } + }, cancellationToken); + return item; + } + + public Task UpdateAsync(ScheduleItem item, CancellationToken cancellationToken = default(CancellationToken)) + { + throw new NotImplementedException(); + } + + public async Task DeleteAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) + { + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Schedule.Delete"); + cmd.AddParameter("@Id", id); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + } + + public async Task ExistsAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) + { + var count = 0; + await ExecuteAsync(async cmd => + { + cmd.CommandText = await SqlLoader.GetScript("Schedule.Exists"); + cmd.AddParameter("@Name", name); + count = (int)await cmd.ExecuteScalarAsync(cancellationToken); + }, cancellationToken); + return count > 0; + } + + private ScheduleItem MapScheduleItem(NpgsqlDataReader rdr) + { + return new ScheduleItem + { + CreatedOn = rdr.Map(nameof(ScheduleItem.CreatedOn).ToLowerInvariant()), + CronExpression = rdr.Map(nameof(ScheduleItem.CronExpression).ToLowerInvariant()), + EnqueuedOn = rdr.Map(nameof(ScheduleItem.EnqueuedOn).ToLowerInvariant()), + EnqueueOn = rdr.Map(nameof(ScheduleItem.EnqueueOn).ToLowerInvariant()), + Id = rdr.Map(nameof(ScheduleItem.Id).ToLowerInvariant()), + Name = rdr.Map(nameof(ScheduleItem.Name).ToLowerInvariant()), + Payload = rdr.Map(nameof(ScheduleItem.Payload).ToLowerInvariant()), + Queue = rdr.Map(nameof(ScheduleItem.Queue).ToLowerInvariant()) + }; + } + + private Task ExecuteAsync(Func func, CancellationToken cancellationToken) + { + return PostgresRunner.ExecuteAsync(func, _connectionString, true, cancellationToken); + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Providers/PostgresWorkProvider.cs b/Workers/Support/Quidjibo.Postgres/Providers/PostgresWorkProvider.cs new file mode 100644 index 00000000..7ad1a670 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Providers/PostgresWorkProvider.cs @@ -0,0 +1,160 @@ +// // Copyright (c) smiggleworth. All rights reserved. +// // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Quidjibo.Models; +using Quidjibo.Providers; +using Quidjibo.Postgres.Extensions; +using Quidjibo.Postgres.Utils; +using Npgsql; + +namespace Quidjibo.Postgres.Providers +{ + public class PostgresWorkProvider : IWorkProvider + { + public enum StatusFlags + { + Faulted = -1, + New = 0, + InFlight = 1, + Complete = 2 + } + + public const int DEFAULT_EXPIRE_DAYS = 7; + + private readonly int _batchSize; + private readonly string _connectionString; + private readonly int _daysToKeep; + private readonly ILogger _logger; + private readonly int _maxAttempts; + private readonly string[] _queues; + private readonly int _visibilityTimeout; + private string _receiveSql; + + public PostgresWorkProvider( + ILogger logger, + string connectionString, + string[] queues, + int visibilityTimeout, + int batchSize, + int daysToKeep + ) + { + _logger = logger; + _queues = queues; + _visibilityTimeout = visibilityTimeout; + _batchSize = batchSize; + _maxAttempts = 10; + _connectionString = connectionString; + _daysToKeep = Math.Abs(daysToKeep); + } + + public async Task SendAsync(WorkItem item, int delay, CancellationToken cancellationToken) + { + await ExecuteAsync(async cmd => + { + await cmd.PrepareForSendAsync(item, delay, cancellationToken); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken).ConfigureAwait(false); + } + + public async Task> ReceiveAsync(string worker, CancellationToken cancellationToken) + { + var receiveOn = DateTime.UtcNow; + var deleteOn = _daysToKeep > 0 ? receiveOn.AddDays(-_daysToKeep) : receiveOn.AddHours(-1); + + if (_receiveSql == null) + { + _receiveSql = await SqlLoader.GetScript("Work.Receive"); + if (_queues.Length > 0) + { + _receiveSql = _receiveSql.Replace("@Queue1", + string.Join(",", _queues.Select((x, i) => $"@Queue{i}"))); + } + } + + var workItems = new List(_batchSize); + await ExecuteAsync(async cmd => + { + cmd.CommandText = _receiveSql; + cmd.AddParameter("@Worker", worker); + cmd.AddParameter("@Take", _batchSize); + cmd.AddParameter("@InFlight", ((int)StatusFlags.InFlight)); + cmd.AddParameter("@VisibleOn", receiveOn.AddSeconds(Math.Max(_visibilityTimeout, 30))); + cmd.AddParameter("@ReceiveOn", receiveOn); + cmd.AddParameter("@MaxAttempts", _maxAttempts); + cmd.AddParameter("@DeleteOn", deleteOn); + + // dynamic parameters + for (var i = 0; i < _queues.Length; i++) + { + cmd.Parameters.AddWithValue($"@Queue{i}", _queues[i]); + } + + using (var rdr = await cmd.ExecuteReaderAsync(cancellationToken)) + { + while (await rdr.ReadAsync(cancellationToken)) + { + var workItem = new WorkItem + { + Attempts = rdr.Map(nameof(WorkItem.Attempts).ToLowerInvariant()), + CorrelationId = rdr.Map(nameof(WorkItem.CorrelationId).ToLowerInvariant()), + ExpireOn = rdr.Map(nameof(WorkItem.ExpireOn).ToLowerInvariant()), + Id = rdr.Map(nameof(WorkItem.Id).ToLowerInvariant()), + Name = rdr.Map(nameof(WorkItem.Name).ToLowerInvariant()), + Payload = rdr.Map(nameof(WorkItem.Payload).ToLowerInvariant()), + Queue = rdr.Map(nameof(WorkItem.Queue).ToLowerInvariant()), + ScheduleId = rdr.Map(nameof(WorkItem.ScheduleId).ToLowerInvariant()) + }; + workItem.Token = workItem.Id.ToString(); + workItems.Add(workItem); + } + } + }, cancellationToken); + return workItems; + } + + public async Task RenewAsync(WorkItem item, CancellationToken cancellationToken) + { + var lockExpireOn = (item.VisibleOn ?? DateTime.UtcNow).AddSeconds(Math.Max(_visibilityTimeout, 30)); + await ExecuteAsync(async cmd => + { + await cmd.PrepareForRenewAsync(item, lockExpireOn, cancellationToken); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + return lockExpireOn; + } + + public async Task CompleteAsync(WorkItem item, CancellationToken cancellationToken) + { + await ExecuteAsync(async cmd => + { + await cmd.PrepareForCompleteAsync(item, cancellationToken); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + } + + public async Task FaultAsync(WorkItem item, CancellationToken cancellationToken) + { + await ExecuteAsync(async cmd => + { + await cmd.PrepareForFaultAsync(item, _visibilityTimeout, cancellationToken); + await cmd.ExecuteNonQueryAsync(cancellationToken); + }, cancellationToken); + } + + public void Dispose() + { + } + + private Task ExecuteAsync(Func func, CancellationToken cancellationToken) + { + return PostgresRunner.ExecuteAsync(func, _connectionString, true, cancellationToken); + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj b/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj new file mode 100644 index 00000000..9997666d --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Quidjibo.Postgres.csproj @@ -0,0 +1,72 @@ + + + + netstandard2.0 + Smiggleworth + Copyright © 2017 + Quidjibo delivers flexible async background jobs for .NET applications + https://quidjibo.com/ + https://github.com/smiggleworth/Quidjibo + Smiggleworth + https://github.com/smiggleworth/Quidjibo/blob/master/LICENSE + async tasks workers cron + false + https://quidjibo.com/images/quidjibo-q.png + 1.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Progress/Create.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Progress/Create.sql new file mode 100644 index 00000000..6bc25c76 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Progress/Create.sql @@ -0,0 +1,22 @@ +INSERT INTO public.progress +( + id, + workid, + correlationid, + name, + queue, + note, + value, + recordedon +) +VALUES +( + @Id, + @WorkId, + @CorrelationId, + @Name, + @Queue, + @Note, + @Value, + @RecordedOn +); diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Progress/LoadByCorrelationId.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Progress/LoadByCorrelationId.sql new file mode 100644 index 00000000..f741130a --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Progress/LoadByCorrelationId.sql @@ -0,0 +1,3 @@ +SELECT id, workid, correlationid, name, queue, note, value, recordedon +FROM public.progress +WHERE correlationid = @correlationid diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Progress/Setup.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Progress/Setup.sql new file mode 100644 index 00000000..98c16783 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Progress/Setup.sql @@ -0,0 +1,23 @@ +DO $$ BEGIN +CREATE TABLE IF NOT EXISTS public.progress( + id uuid NOT NULL, + sequence bigserial, + workid uuid, + correlationid uuid NOT NULL, + name character varying(250) NOT NULL, + queue character varying(250) NOT NULL, + note character varying(250) NOT NULL, + value integer NOT NULL, + recordedon timestamp without time zone +); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'progress' and constraint_type = 'PRIMARY KEY') THEN +ALTER TABLE public.progress + ADD PRIMARY KEY (id); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'progress' and constraint_type = 'UNIQUE') THEN +ALTER TABLE public.progress + ADD CONSTRAINT progress_sequence_key UNIQUE(sequence); +END IF; +END $$; diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Complete.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Complete.sql new file mode 100644 index 00000000..e234f20a --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Complete.sql @@ -0,0 +1,4 @@ +UPDATE public.schedule +SET enqueuedon = @EnqueuedOn, + enqueueon = @EnqueueOn +WHERE id = @Id diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Create.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Create.sql new file mode 100644 index 00000000..98000935 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Create.sql @@ -0,0 +1,24 @@ +INSERT INTO public.schedule +( + id, + name, + queue, + cronexpression, + createdon, + enqueueon, + enqueuedon, + visibleon, + payload +) +VALUES +( + @Id, + @Name, + @Queue, + @CronExpression, + @CreatedOn, + @EnqueueOn, + @EnqueuedOn, + @VisibleOn, + @Payload +); diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Delete.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Delete.sql new file mode 100644 index 00000000..6ab51515 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Delete.sql @@ -0,0 +1 @@ +DELETE FROM public.schedule WHERE id = @Id diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Exists.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Exists.sql new file mode 100644 index 00000000..d512e2b8 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Exists.sql @@ -0,0 +1,3 @@ +SELECT COUNT(*) +FROM public.schedule +WHERE name = @Name diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/List.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/List.sql new file mode 100644 index 00000000..3003ee54 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/List.sql @@ -0,0 +1 @@ +SELECT TOP(@Take) public.schedule.* diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Load.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Load.sql new file mode 100644 index 00000000..fa78d631 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Load.sql @@ -0,0 +1,3 @@ +SELECT * +FROM public.schedule +WHERE id = @Id diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/LoadByName.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/LoadByName.sql new file mode 100644 index 00000000..0dd893b8 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/LoadByName.sql @@ -0,0 +1,3 @@ +SELECT * +FROM public.schedule +WHERE name = @Name diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Receive.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Receive.sql new file mode 100644 index 00000000..88fe3157 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Receive.sql @@ -0,0 +1,15 @@ +WITH schdl AS +( + SELECT public.schedule.* + FROM public.schedule + WHERE visibleon < @ReceiveOn + AND enqueueon < @ReceiveOn + AND queue IN (@Queue1) + ORDER BY id + LIMIT @Take +) +UPDATE public.schedule +SET visibleon = @VisibleOn +FROM schdl +WHERE public.schedule.id = schdl.id +RETURNING *; diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Setup.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Setup.sql new file mode 100644 index 00000000..052e839f --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schedule/Setup.sql @@ -0,0 +1,24 @@ +DO $$ BEGIN +CREATE TABLE IF NOT EXISTS public.schedule( + id uuid NOT NULL, + sequence bigserial, + name character varying(250) NOT NULL, + queue character varying(250) NOT NULL, + cronexpression character varying(50) NOT NULL, + createdon timestamp without time zone, + enqueueon timestamp without time zone, + enqueuedon timestamp without time zone, + visibleon timestamp without time zone, + payload bytea NOT NULL +); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'schedule' and constraint_type = 'PRIMARY KEY') THEN +ALTER TABLE public.schedule + ADD PRIMARY KEY (id); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'schedule' and constraint_type = 'UNIQUE') THEN +ALTER TABLE public.schedule + ADD CONSTRAINT schedule_sequence_key UNIQUE(sequence); +END IF; +END $$; diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Schema/Setup.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Schema/Setup.sql new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Schema/Setup.sql @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/Complete.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Complete.sql new file mode 100644 index 00000000..86a2ab48 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Complete.sql @@ -0,0 +1,5 @@ +UPDATE public.work +SET expireon = NULL, + visibleon = Null, + status = @Complete +WHERE id = @Id diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/Fault.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Fault.sql new file mode 100644 index 00000000..2292a3d4 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Fault.sql @@ -0,0 +1,5 @@ +UPDATE wrk +SET visibleon = @VisibleOn, + status = @Faulted +FROM public.work wrk +WHERE id = @Id diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/List.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/List.sql new file mode 100644 index 00000000..c4ccd9ca --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/List.sql @@ -0,0 +1 @@ +-- List of work items in all states \ No newline at end of file diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/Receive.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Receive.sql new file mode 100644 index 00000000..906b3544 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Receive.sql @@ -0,0 +1,23 @@ +DELETE FROM public.work +WHERE createdon < @DeleteOn + AND (expireon IS NULL OR expireon < @DeleteOn); + +WITH wrk AS +( + SELECT public.work.* + FROM public.work + WHERE Status < 2 + AND attempts < @MaxAttempts + AND visibleon < @ReceiveOn + AND queue IN (@Queue1) + ORDER BY id + LIMIT @Take +) +UPDATE public.work +SET worker = @Worker, + visibleon = @VisibleOn, + status = @InFlight, + attempts = public.work.attempts + 1 +FROM wrk +WHERE public.work.id = wrk.id +RETURNING *; diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/Renew.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Renew.sql new file mode 100644 index 00000000..c52d8bfb --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Renew.sql @@ -0,0 +1,3 @@ +UPDATE public.work +SET visibleon = @VisibleOn +WHERE id = @Id diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/Send.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Send.sql new file mode 100644 index 00000000..2bdd9b64 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Send.sql @@ -0,0 +1,30 @@ +INSERT INTO public.work +( + id, + scheduleid, + correlationid, + name, + worker, + queue, + attempts, + createdon, + expireon, + visibleon, + status, + payload +) +VALUES +( + @Id, + @ScheduleId, + @CorrelationId, + @Name, + @Worker, + @Queue, + @Attempts, + @CreatedOn, + @ExpireOn, + @VisibleOn, + @Status, + @Payload +) diff --git a/Workers/Support/Quidjibo.Postgres/Scripts/Work/Setup.sql b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Setup.sql new file mode 100644 index 00000000..36f357e1 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Scripts/Work/Setup.sql @@ -0,0 +1,27 @@ +DO $$ BEGIN +CREATE TABLE IF NOT EXISTS public.work( + id uuid NOT NULL, + sequence bigserial, + scheduleid uuid, + correlationid uuid NOT NULL, + name character varying(250) NOT NULL, + worker character varying(250), + queue character varying(250) NOT NULL, + status integer NOT NULL, + attempts integer NOT NULL, + createdon timestamp without time zone, + expireon timestamp without time zone, + visibleon timestamp without time zone, + payload bytea NOT NULL +); + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'work' and constraint_type = 'PRIMARY KEY') THEN +ALTER TABLE public.work + ADD PRIMARY KEY (id); +END IF; + +IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'work' and constraint_type = 'UNIQUE') THEN +ALTER TABLE public.work + ADD CONSTRAINT work_sequence_key UNIQUE(sequence); +END IF; +END $$; diff --git a/Workers/Support/Quidjibo.Postgres/Utils/PostgresRunner.cs b/Workers/Support/Quidjibo.Postgres/Utils/PostgresRunner.cs new file mode 100644 index 00000000..03def9f1 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Utils/PostgresRunner.cs @@ -0,0 +1,59 @@ +using Npgsql; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace Quidjibo.Postgres.Utils +{ + public static class PostgresRunner + { + public static Task ExecuteAsync(Func func, string connectionString, CancellationToken cancellationToken) + { + return ExecuteAsync(func, connectionString, true, cancellationToken); + } + + public static async Task ExecuteAsync(Func func, string connectionString, bool inTransaction, CancellationToken cancellationToken) + { + using (var conn = new NpgsqlConnection(connectionString)) + using (var cmd = conn.CreateCommand()) + { + { + await conn.OpenAsync(cancellationToken); + if (inTransaction) + { + using (var tran = conn.BeginTransaction()) + { + try + { + cmd.Transaction = tran; + await func(cmd); + await tran.CommitAsync(); + } + catch (Exception ex) + { + await tran.RollbackAsync(); + throw; + } + } + + return; + } + + await func(cmd); + } + } + } + + + public static T Map(this NpgsqlDataReader rdr, string name) + { + var val = rdr[name]; + if (val == DBNull.Value) + { + return default(T); + } + + return (T)val; + } + } +} diff --git a/Workers/Support/Quidjibo.Postgres/Utils/SqlLoader.cs b/Workers/Support/Quidjibo.Postgres/Utils/SqlLoader.cs new file mode 100644 index 00000000..8a7bc701 --- /dev/null +++ b/Workers/Support/Quidjibo.Postgres/Utils/SqlLoader.cs @@ -0,0 +1,31 @@ +using System.Collections.Concurrent; +using System.IO; +using System.Reflection; +using System.Threading.Tasks; + +namespace Quidjibo.Postgres.Utils +{ + public class SqlLoader + { + private static readonly ConcurrentDictionary Scripts = new ConcurrentDictionary(); + + public static async Task GetScript(string scriptName) + { + if (Scripts.TryGetValue(scriptName, out var script)) + { + return script; + } + + var assembly = typeof(SqlLoader).GetTypeInfo().Assembly; + var fullName = $"Quidjibo.Postgres.Scripts.{scriptName}.sql"; + using (var stream = assembly.GetManifestResourceStream(fullName) ?? new MemoryStream()) + using (var reader = new StreamReader(stream)) + { + script = await reader.ReadToEndAsync(); + Scripts.TryAdd(scriptName, script); + } + + return script; + } + } +}