Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
ProjectsStatusManagement
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hasan.bahjat
ProjectsStatusManagement
Commits
626a2c9b
Commit
626a2c9b
authored
Aug 25, 2024
by
hasan khaddour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
read settings from appsitting
parent
bf203fbc
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1312 additions
and
12 deletions
+1312
-12
DependencyInjection.cs
...e/DependencyInjectionConfiguration/DependencyInjection.cs
+2
-1
ProjectEntityConfiguration.cs
...tence/EntitiesConfiguration/ProjectEntityConfiguration.cs
+3
-1
20240825084539_AddProjectTypeForegin.Designer.cs
...grations/20240825084539_AddProjectTypeForegin.Designer.cs
+1193
-0
20240825084539_AddProjectTypeForegin.cs
...stence/Migrations/20240825084539_AddProjectTypeForegin.cs
+55
-0
AppDbContextModelSnapshot.cs
...cture.Persistence/Migrations/AppDbContextModelSnapshot.cs
+4
-2
FinancialSpendingRepository.cs
.../FinancialSpendsRepository/FinancialSpendingRepository.cs
+1
-0
ProjectsTypesRepository.cs
...Repositories/ProjectRepository/ProjectsTypesRepository.cs
+27
-0
CronJobSyncEmployees.cs
...t.Infrastructure/CronJobsServices/CronJobSyncEmployees.cs
+2
-2
DependencyInjection.cs
...e/DependencyInjectionConfiguration/DependencyInjection.cs
+6
-3
EmployeesSyncJobSettings.cs
...ement.Infrastructure/Settings/EmployeesSyncJobSettings.cs
+0
-1
FileServiceSettings.cs
PSManagement.Infrastructure/Settings/FileServiceSettings.cs
+10
-0
FileService.cs
PSManagement.Infrastructure/Storage/FileService.cs
+9
-2
No files found.
PSManagement.Infrastructure.Persistence/D
I
/DependencyInjection.cs
→
PSManagement.Infrastructure.Persistence/D
ependencyInjectionConfiguration
/DependencyInjection.cs
View file @
626a2c9b
...
@@ -38,7 +38,8 @@ namespace PSManagement.Infrastructure.Persistence.DI
...
@@ -38,7 +38,8 @@ namespace PSManagement.Infrastructure.Persistence.DI
services
.
AddScoped
<
IEmployeesRepository
,
EmployeesRespository
>();
services
.
AddScoped
<
IEmployeesRepository
,
EmployeesRespository
>();
services
.
AddScoped
<
IStepsRepository
,
StepsRepository
>();
services
.
AddScoped
<
IStepsRepository
,
StepsRepository
>();
services
.
AddScoped
<
IFinancialSpendingRepository
,
FinancialSpendingRepository
>();
services
.
AddScoped
<
IFinancialSpendingRepository
,
FinancialSpendingRepository
>();
services
.
AddScoped
<
ITracksRepository
,
TracksRepository
>();
services
.
AddScoped
<
ITracksRepository
,
TracksRepository
>();
services
.
AddScoped
<
IProjectTypesRepository
,
ProjectsTypesRepository
>();
services
.
AddScoped
<
ProjectBuilder
>();
services
.
AddScoped
<
ProjectBuilder
>();
services
.
AddScoped
(
typeof
(
IRepository
<>),
typeof
(
BaseRepository
<>));
services
.
AddScoped
(
typeof
(
IRepository
<>),
typeof
(
BaseRepository
<>));
...
...
PSManagement.Infrastructure.Persistence/EntitiesConfiguration/ProjectEntityConfiguration.cs
View file @
626a2c9b
...
@@ -34,7 +34,8 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
...
@@ -34,7 +34,8 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
);
);
builder
.
HasOne
(
e
=>
e
.
ProjectType
)
builder
.
HasOne
(
e
=>
e
.
ProjectType
)
.
WithMany
();
.
WithMany
()
.
HasForeignKey
(
e
=>
e
.
ProjectTypeId
);
...
@@ -93,6 +94,7 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
...
@@ -93,6 +94,7 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
{
builder
.
HasOne
(
e
=>
e
.
Project
)
builder
.
HasOne
(
e
=>
e
.
Project
)
.
WithOne
(
e
=>
e
.
ProjectCompletion
)
.
WithOne
(
e
=>
e
.
ProjectCompletion
)
;
;
}
}
}
}
...
...
PSManagement.Infrastructure.Persistence/Migrations/20240825084539_AddProjectTypeForegin.Designer.cs
0 → 100644
View file @
626a2c9b
This diff is collapsed.
Click to expand it.
PSManagement.Infrastructure.Persistence/Migrations/20240825084539_AddProjectTypeForegin.cs
0 → 100644
View file @
626a2c9b
using
Microsoft.EntityFrameworkCore.Migrations
;
namespace
PSManagement.Infrastructure.Persistence.Migrations
{
public
partial
class
AddProjectTypeForegin
:
Migration
{
protected
override
void
Up
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_Projects_ProjectType_ProjectTypeId"
,
table
:
"Projects"
);
migrationBuilder
.
AlterColumn
<
int
>(
name
:
"ProjectTypeId"
,
table
:
"Projects"
,
type
:
"int"
,
nullable
:
true
,
defaultValue
:
0
,
oldClrType
:
typeof
(
int
),
oldType
:
"int"
,
oldNullable
:
true
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_Projects_ProjectType_ProjectTypeId"
,
table
:
"Projects"
,
column
:
"ProjectTypeId"
,
principalTable
:
"ProjectType"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Cascade
);
}
protected
override
void
Down
(
MigrationBuilder
migrationBuilder
)
{
migrationBuilder
.
DropForeignKey
(
name
:
"FK_Projects_ProjectType_ProjectTypeId"
,
table
:
"Projects"
);
migrationBuilder
.
AlterColumn
<
int
>(
name
:
"ProjectTypeId"
,
table
:
"Projects"
,
type
:
"int"
,
nullable
:
true
,
oldClrType
:
typeof
(
int
),
oldType
:
"int"
);
migrationBuilder
.
AddForeignKey
(
name
:
"FK_Projects_ProjectType_ProjectTypeId"
,
table
:
"Projects"
,
column
:
"ProjectTypeId"
,
principalTable
:
"ProjectType"
,
principalColumn
:
"Id"
,
onDelete
:
ReferentialAction
.
Restrict
);
}
}
}
PSManagement.Infrastructure.Persistence/Migrations/AppDbContextModelSnapshot.cs
View file @
626a2c9b
...
@@ -315,7 +315,7 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -315,7 +315,7 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
Property
<
int
>(
"ProjectManagerId"
)
b
.
Property
<
int
>(
"ProjectManagerId"
)
.
HasColumnType
(
"int"
);
.
HasColumnType
(
"int"
);
b
.
Property
<
int
?
>(
"ProjectTypeId"
)
b
.
Property
<
int
>(
"ProjectTypeId"
)
.
HasColumnType
(
"int"
);
.
HasColumnType
(
"int"
);
b
.
Property
<
int
?>(
"ProjectTypeId1"
)
b
.
Property
<
int
?>(
"ProjectTypeId1"
)
...
@@ -745,7 +745,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
...
@@ -745,7 +745,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b
.
HasOne
(
"PSManagement.Domain.Projects.Entities.ProjectType"
,
"ProjectType"
)
b
.
HasOne
(
"PSManagement.Domain.Projects.Entities.ProjectType"
,
"ProjectType"
)
.
WithMany
()
.
WithMany
()
.
HasForeignKey
(
"ProjectTypeId"
);
.
HasForeignKey
(
"ProjectTypeId"
)
.
OnDelete
(
DeleteBehavior
.
Cascade
)
.
IsRequired
();
b
.
HasOne
(
"PSManagement.Domain.Projects.Entities.ProjectType"
,
null
)
b
.
HasOne
(
"PSManagement.Domain.Projects.Entities.ProjectType"
,
null
)
.
WithMany
(
"Projects"
)
.
WithMany
(
"Projects"
)
...
...
PSManagement.Infrastructure.Persistence/Repositories/
Project
Repository/FinancialSpendingRepository.cs
→
PSManagement.Infrastructure.Persistence/Repositories/
FinancialSpends
Repository/FinancialSpendingRepository.cs
View file @
626a2c9b
...
@@ -10,4 +10,5 @@ namespace PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
...
@@ -10,4 +10,5 @@ namespace PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
{
{
}
}
}
}
}
}
PSManagement.Infrastructure.Persistence/Repositories/ProjectRepository/ProjectsTypesRepository.cs
0 → 100644
View file @
626a2c9b
using
Microsoft.EntityFrameworkCore
;
using
PSManagement.Domain.Projects.Entities
;
using
PSManagement.Domain.Projects.Repositories
;
using
PSManagement.Infrastructure.Persistence.Repositories.Base
;
using
PSManagement.SharedKernel.Interfaces
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
{
public
class
ProjectsTypesRepository
:
BaseRepository
<
ProjectType
>,
IProjectTypesRepository
{
public
ProjectsTypesRepository
(
AppDbContext
context
)
:
base
(
context
)
{
}
public
async
Task
<
IEnumerable
<
ProjectType
>>
GetByTypeName
(
string
typeName
,
ISpecification
<
ProjectType
>
specification
=
null
)
{
IQueryable
<
ProjectType
>
query
=
ApplySpecification
(
specification
);
return
await
query
.
Where
(
e
=>
e
.
TypeName
==
typeName
).
ToListAsync
();
}
}
}
PSManagement.Infrastructure/
BackgroundServcies/Background
JobSyncEmployees.cs
→
PSManagement.Infrastructure/
CronJobsServices/Cron
JobSyncEmployees.cs
View file @
626a2c9b
...
@@ -10,12 +10,12 @@ using System.Threading.Tasks;
...
@@ -10,12 +10,12 @@ using System.Threading.Tasks;
namespace
PSManagement.Infrastructure.BackgroundServcies
namespace
PSManagement.Infrastructure.BackgroundServcies
{
{
public
class
Background
JobSyncEmployees
:
BackgroundService
public
class
Cron
JobSyncEmployees
:
BackgroundService
{
{
private
readonly
IServiceScopeFactory
_scopeFactory
;
private
readonly
IServiceScopeFactory
_scopeFactory
;
private
readonly
int
_syncIntervalInMinutes
;
private
readonly
int
_syncIntervalInMinutes
;
public
Background
JobSyncEmployees
(
public
Cron
JobSyncEmployees
(
IOptions
<
EmployeesSyncJobSettings
>
settings
,
IOptions
<
EmployeesSyncJobSettings
>
settings
,
IServiceScopeFactory
scopeFactory
)
IServiceScopeFactory
scopeFactory
)
{
{
...
...
PSManagement.Infrastructure/D
I
/DependencyInjection.cs
→
PSManagement.Infrastructure/D
ependencyInjectionConfiguration
/DependencyInjection.cs
View file @
626a2c9b
...
@@ -31,14 +31,16 @@ namespace PSManagement.Infrastructure.DI
...
@@ -31,14 +31,16 @@ namespace PSManagement.Infrastructure.DI
services
services
.
AddAuthentication
(
configuration
)
.
AddAuthentication
(
configuration
)
.
AddAuthorization
()
.
AddAuthorization
()
.
AddServices
()
.
AddServices
(
configuration
)
.
AddBackgroundServices
(
configuration
);
.
AddBackgroundServices
(
configuration
);
return
services
;
return
services
;
}
}
private
static
IServiceCollection
AddServices
(
this
IServiceCollection
services
)
private
static
IServiceCollection
AddServices
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
{
services
.
Configure
<
FileServiceSettings
>(
configuration
.
GetSection
(
FileServiceSettings
.
SectionName
));
services
.
AddSingleton
<
IDateTimeProvider
,
DateTimeProvider
>();
services
.
AddSingleton
<
IDateTimeProvider
,
DateTimeProvider
>();
services
.
AddScoped
<
IEmployeesProvider
,
EmployeesProvider
>();
services
.
AddScoped
<
IEmployeesProvider
,
EmployeesProvider
>();
services
.
AddScoped
<
ICurrentUserProvider
,
CurrentUserProvider
>();
services
.
AddScoped
<
ICurrentUserProvider
,
CurrentUserProvider
>();
...
@@ -54,7 +56,7 @@ namespace PSManagement.Infrastructure.DI
...
@@ -54,7 +56,7 @@ namespace PSManagement.Infrastructure.DI
services
.
AddScoped
<
ISyncEmployeesService
,
SyncEmployeesService
>();
services
.
AddScoped
<
ISyncEmployeesService
,
SyncEmployeesService
>();
services
.
AddScoped
<
IOccupancySystemNotifier
,
OccupancySystemNotifier
>();
services
.
AddScoped
<
IOccupancySystemNotifier
,
OccupancySystemNotifier
>();
services
.
AddHostedService
<
Background
JobSyncEmployees
>();
services
.
AddHostedService
<
Cron
JobSyncEmployees
>();
return
services
;
return
services
;
}
}
...
@@ -71,6 +73,7 @@ namespace PSManagement.Infrastructure.DI
...
@@ -71,6 +73,7 @@ namespace PSManagement.Infrastructure.DI
private
static
IServiceCollection
AddAuthentication
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
private
static
IServiceCollection
AddAuthentication
(
this
IServiceCollection
services
,
IConfiguration
configuration
)
{
{
services
.
Configure
<
JwtSetting
>(
configuration
.
GetSection
(
JwtSetting
.
Section
));
services
.
Configure
<
JwtSetting
>(
configuration
.
GetSection
(
JwtSetting
.
Section
));
services
.
AddSingleton
<
IJwtTokenGenerator
,
JwtTokenGenerator
>();
services
.
AddSingleton
<
IJwtTokenGenerator
,
JwtTokenGenerator
>();
services
.
AddScoped
<
IAuthenticationService
,
AuthenticationService
>();
services
.
AddScoped
<
IAuthenticationService
,
AuthenticationService
>();
...
...
PSManagement.Infrastructure/Settings/EmployeesSyncJobSettings.cs
View file @
626a2c9b
...
@@ -4,5 +4,4 @@
...
@@ -4,5 +4,4 @@
{
{
public
int
SyncIntervalInMinutes
{
get
;
set
;
}
public
int
SyncIntervalInMinutes
{
get
;
set
;
}
}
}
}
}
PSManagement.Infrastructure/Settings/FileServiceSettings.cs
0 → 100644
View file @
626a2c9b
namespace
PSManagement.Infrastructure.Settings
{
public
class
FileServiceSettings
{
public
const
string
SectionName
=
"FileServiceSettings"
;
public
string
[]
AvailableExtension
{
get
;
set
;
}
=
null
!;
}
}
PSManagement.Infrastructure/Storage/FileService.cs
View file @
626a2c9b
using
Ardalis.Result
;
using
Ardalis.Result
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.Extensions.Options
;
using
PSManagement.Application.Contracts.Storage
;
using
PSManagement.Application.Contracts.Storage
;
using
PSManagement.Infrastructure.Settings
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
...
@@ -12,9 +14,14 @@ namespace PSManagement.Infrastructure.Services.Storage
...
@@ -12,9 +14,14 @@ namespace PSManagement.Infrastructure.Services.Storage
{
{
public
class
FileService
:
IFileService
public
class
FileService
:
IFileService
{
{
private
readonly
string
[]
_availableExtension
;
public
FileService
(
IOptions
<
FileServiceSettings
>
fileServiceOptions
)
{
_availableExtension
=
fileServiceOptions
.
Value
.
AvailableExtension
;
}
public
async
Task
<
Result
<
String
>>
StoreFile
(
string
fileName
,
IFormFile
file
)
public
async
Task
<
Result
<
String
>>
StoreFile
(
string
fileName
,
IFormFile
file
)
{
{
var
allowedExtensions
=
new
string
[]
{
".pdf"
,
".png"
};
if
(
file
is
null
)
if
(
file
is
null
)
{
{
return
Result
.
Invalid
(
new
ValidationError
(
"File couldn't be empty."
));
return
Result
.
Invalid
(
new
ValidationError
(
"File couldn't be empty."
));
...
@@ -22,7 +29,7 @@ namespace PSManagement.Infrastructure.Services.Storage
...
@@ -22,7 +29,7 @@ namespace PSManagement.Infrastructure.Services.Storage
}
}
var
extension
=
Path
.
GetExtension
(
file
.
FileName
);
var
extension
=
Path
.
GetExtension
(
file
.
FileName
);
if
(!
allowedExtensions
.
Contains
(
extension
.
ToLower
()))
if
(!
_availableExtension
.
Contains
(
extension
.
ToLower
()))
{
{
return
Result
.
Invalid
(
new
ValidationError
(
"File type not allowed."
));
return
Result
.
Invalid
(
new
ValidationError
(
"File type not allowed."
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment