Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
find-with-test
Project
Project
Details
Activity
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
Alan Farhadi
find-with-test
Commits
1d8619b3
Commit
1d8619b3
authored
Sep 08, 2020
by
alan.f
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add-serlog-config
parent
bca58d5e
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
55 additions
and
39 deletions
+55
-39
Dockerfile
Dockerfile
+5
-1
DicomFileTransferController.cs
...Service.Client/Controllers/DicomFileTransferController.cs
+6
-3
FindDicomFileController.cs
...angeService.Client/Controllers/FindDicomFileController.cs
+2
-0
ExchangeService.Client.csproj
ExchangeService.Client/ExchangeService.Client.csproj
+1
-0
ExchangeService.Client.csproj.user
ExchangeService.Client/ExchangeService.Client.csproj.user
+2
-1
launchSettings.json
ExchangeService.Client/Properties/launchSettings.json
+0
-8
SeriLogConfig.cs
ExchangeService.Client/SerilogConfig/SeriLogConfig.cs
+1
-1
Startup.cs
ExchangeService.Client/Startup.cs
+7
-1
ExchangeService.GrpcServer.csproj.user
...Service.GrpcServer/ExchangeService.GrpcServer.csproj.user
+2
-1
Program.cs
ExchangeService.GrpcServer/Program.cs
+1
-11
SeriLogConfig.cs
ExchangeService.GrpcServer/SerilogConfig/SeriLogConfig.cs
+1
-1
DicomFileOperationService.cs
...eService.GrpcServer/Services/DicomFileOperationService.cs
+8
-6
Startup.cs
ExchangeService.GrpcServer/Startup.cs
+14
-0
DicomFileTransferServerTests.cs
ExchangeService.Test/DicomFileTransferServerTests.cs
+5
-5
No files found.
Dockerfile
View file @
1d8619b3
...
...
@@ -19,9 +19,13 @@ RUN dotnet restore "ExchangeService.Client.csproj"
RUN
dotnet build
-c
Release
-o
/app2
WORKDIR
"/src/ExchangeService.Test"
RUN
dotnet restore
"
ExchangeService
.Test.csproj"
RUN
dotnet restore
"
UnitTest/ExchangeServiceClient
.Test.csproj"
RUN
dotnet build
-c
Release
-o
/app3
WORKDIR
"/src/ExchangeService.Test"
RUN
dotnet restore
"UnitTest/ExchangeServiceGrpcServer.Test.csproj"
RUN
dotnet build
-c
Release
-o
/app4
FROM
base AS final
WORKDIR
/app
...
...
ExchangeService.Client/Controllers/DicomFileTransferController.cs
View file @
1d8619b3
...
...
@@ -17,8 +17,9 @@ using Serilog;
namespace
ExchangeService.Client.Controllers
{
[
Route
(
"api/[controller]"
)]
[
ApiController
]
[
Route
(
"[controller]"
)]
public
class
DicomTransferFileController
:
ControllerBase
{
#
region
Properties
...
...
@@ -42,6 +43,8 @@ namespace ExchangeService.Client.Controllers
[
HttpPost
]
public
async
Task
Post
([
FromForm
]
Models
.
FilesPackage
queryFilters
)
{
Log
.
Information
(
"DicomTransferFile Started ...!"
);
SendCallback
sc
=
new
SendCallback
();
string
connectionString
=
_configuration
.
GetConnectionString
(
"DefaultConnection"
);
string
view
=
_configuration
[
"Views:ImageDetails"
];
...
...
@@ -65,7 +68,7 @@ namespace ExchangeService.Client.Controllers
});
});
var
channel
=
GrpcChannel
.
ForAddress
(
"https://localhost:
8098
"
);
var
channel
=
GrpcChannel
.
ForAddress
(
"https://localhost:
5001
"
);
var
client
=
new
DicomOps
.
DicomOpsClient
(
channel
);
_uploadedFiles
.
ToObservable
().
Subscribe
(
uploadedFile
=>
{
...
...
@@ -85,7 +88,7 @@ namespace ExchangeService.Client.Controllers
Log
.
Error
(
"There is no file to send"
);
sc
.
OnOperationFailed
();
}
Log
.
Information
(
"operation
success
ed!"
);
Log
.
Information
(
"operation
Finish
ed!"
);
sc
.
OnSendingFinished
();
}
#
endregion
...
...
ExchangeService.Client/Controllers/FindDicomFileController.cs
View file @
1d8619b3
...
...
@@ -3,6 +3,7 @@ using ExchangeService.Client.Models;
using
ExchangeService.GrpcServer
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Configuration
;
using
Serilog
;
using
System
;
using
System.Collections.Generic
;
using
System.Data.SqlClient
;
...
...
@@ -28,6 +29,7 @@ namespace DicomTransferFileApi.Client.Controllers
[
HttpPost
]
public
async
Task
<
List
<
DicomFilesTransferModel
>>
Post
([
FromForm
]
ExchangeService
.
Client
.
Models
.
FilesPackage
inputsDto
)
{
Log
.
Information
(
"FindDicomFile Started ...!"
);
string
connectionString
=
configuration
!=
null
?
configuration
.
GetConnectionString
(
"DefaultConnection"
)
:
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=mv"
;
string
view
=
configuration
!=
null
?
configuration
[
"Views:ImageDetails"
]
:
"vw_image_details"
;
...
...
ExchangeService.Client/ExchangeService.Client.csproj
View file @
1d8619b3
...
...
@@ -27,6 +27,7 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="System.Reactive" Version="4.4.1" />
</ItemGroup>
...
...
ExchangeService.Client/ExchangeService.Client.csproj.user
View file @
1d8619b3
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<ActiveDebugProfile>
Docker
</ActiveDebugProfile>
<ActiveDebugProfile>
IIS Express
</ActiveDebugProfile>
</PropertyGroup>
</Project>
\ No newline at end of file
ExchangeService.Client/Properties/launchSettings.json
View file @
1d8619b3
...
...
@@ -22,13 +22,6 @@
"ASPNETCORE_ENVIRONMENT"
:
"Development"
},
"applicationUrl"
:
"https://localhost:5001;http://localhost:5000"
},
"Docker"
:
{
"commandName"
:
"Docker"
,
"launchBrowser"
:
true
,
"launchUrl"
:
"{Scheme}://{ServiceHost}:{ServicePort}"
,
"publishAllPorts"
:
true
,
"useSSL"
:
true
}
}
}
\ No newline at end of file
ExchangeService.Client/SerilogConfig/SeriLogConfig.cs
View file @
1d8619b3
...
...
@@ -42,7 +42,7 @@ namespace ExchangeService.Client.SerilogConfig
.
MinimumLevel
.
ControlledBy
(
levelSwitch
)
.
Enrich
.
WithCaller
()
.
WriteTo
.
Console
(
outputTemplate
:
@"time=""{Timestamp:HH:mm:ss.fff}"" app=""{App}"" action=""{Action}"" level=""{Level:u3}"" msg=""{Message}""{NewLine:l}{Exception:l}"
)
.
WriteTo
.
File
(
@"
c:\log
\msrcore-client.txt"
,
outputTemplate
:
@"time=""{Timestamp:HH:mm:ss.fff}"" app=""{App}"" action=""{Action}"" level=""{Level:u3}"" msg=""{Message}""{NewLine:l}{Exception:l}"
,
.
WriteTo
.
File
(
@"
d:\logs
\msrcore-client.txt"
,
outputTemplate
:
@"time=""{Timestamp:HH:mm:ss.fff}"" app=""{App}"" action=""{Action}"" level=""{Level:u3}"" msg=""{Message}""{NewLine:l}{Exception:l}"
,
fileSizeLimitBytes
:
10485760
,
rollingInterval
:
RollingInterval
.
Day
,
shared
:
true
,
rollOnFileSizeLimit
:
true
);
...
...
ExchangeService.Client/Startup.cs
View file @
1d8619b3
...
...
@@ -24,6 +24,8 @@ namespace ExchangeService.Client
public
void
ConfigureServices
(
IServiceCollection
services
)
{
services
.
AddRazorPages
();
services
.
AddControllers
();
services
.
AddSwaggerGen
();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
@@ -39,7 +41,11 @@ namespace ExchangeService.Client
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app
.
UseHsts
();
}
app
.
UseSwagger
();
app
.
UseSwaggerUI
(
c
=>
{
c
.
SwaggerEndpoint
(
"/swagger/v1/swagger.json"
,
"My API V1"
);
});
app
.
UseHttpsRedirection
();
app
.
UseStaticFiles
();
...
...
ExchangeService.GrpcServer/ExchangeService.GrpcServer.csproj.user
View file @
1d8619b3
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<ActiveDebugProfile>
Dock
er
</ActiveDebugProfile>
<ActiveDebugProfile>
ExchangeService.GrpcServ
er
</ActiveDebugProfile>
</PropertyGroup>
</Project>
\ No newline at end of file
ExchangeService.GrpcServer/Program.cs
View file @
1d8619b3
...
...
@@ -14,17 +14,7 @@ namespace ExchangeService.GrpcServer
{
public
static
void
Main
(
string
[]
args
)
{
var
resp
=
SeriLogConfig
.
LoggerConfiguration
(
Serilog
.
Events
.
LogEventLevel
.
Debug
);
if
(!
resp
.
Result
)
{
Console
.
WriteLine
(
resp
.
Log
);
return
;
}
SeriLogConfig
.
LoggerConfiguration
(
Serilog
.
Events
.
LogEventLevel
.
Information
);
Log
.
Information
(
"Starting ExchangeService.GrpcServer ..."
);
CreateHostBuilder
(
args
).
Build
().
Run
();
}
...
...
ExchangeService.GrpcServer/SerilogConfig/SeriLogConfig.cs
View file @
1d8619b3
...
...
@@ -42,7 +42,7 @@ namespace ExchangeService.GrpcServer.SerilogConfig
.
MinimumLevel
.
ControlledBy
(
levelSwitch
)
.
Enrich
.
WithCaller
()
.
WriteTo
.
Console
(
outputTemplate
:
@"time=""{Timestamp:HH:mm:ss.fff}"" app=""{App}"" action=""{Action}"" level=""{Level:u3}"" msg=""{Message}""{NewLine:l}{Exception:l}"
)
.
WriteTo
.
File
(
@"
c:\log
\msrcore-server.txt"
,
outputTemplate
:
@"time=""{Timestamp:HH:mm:ss.fff}"" app=""{App}"" action=""{Action}"" level=""{Level:u3}"" msg=""{Message}""{NewLine:l}{Exception:l}"
,
.
WriteTo
.
File
(
@"
d:\logs
\msrcore-server.txt"
,
outputTemplate
:
@"time=""{Timestamp:HH:mm:ss.fff}"" app=""{App}"" action=""{Action}"" level=""{Level:u3}"" msg=""{Message}""{NewLine:l}{Exception:l}"
,
fileSizeLimitBytes
:
10485760
,
rollingInterval
:
RollingInterval
.
Day
,
shared
:
true
,
rollOnFileSizeLimit
:
true
);
...
...
ExchangeService.GrpcServer/Services/DicomFileOperationService.cs
View file @
1d8619b3
...
...
@@ -3,22 +3,19 @@ using System.Threading.Tasks;
using
Dicom.Network
;
using
Grpc.Core
;
using
Microsoft.Extensions.Logging
;
using
Serilog
;
using
DicomClient
=
Dicom
.
Network
.
Client
.
DicomClient
;
namespace
ExchangeService.GrpcServer
{
public
class
DicomFileOperationService
:
DicomOps
.
DicomOpsBase
{
private
readonly
ILogger
_logger
;
public
DicomFileOperationService
(
ILoggerFactory
loggerFactory
)
{
_logger
=
loggerFactory
.
CreateLogger
<
DicomFileOperationService
>();
}
public
override
async
Task
TransferDicomFiles
(
DicomFilesTransferModel
request
,
IServerStreamWriter
<
DicomFilesTransferResponse
>
responseStream
,
ServerCallContext
context
)
{
Log
.
Information
(
"DicomTransferFile Started ...!"
);
var
client
=
new
DicomClient
(
"127.0.0.1"
,
104
,
false
,
"MARCO"
,
"ANY-SCP"
);
//var client = new DicomClient(request.ServerHost, request.Port, false, request.ServerAET, request.Aet);
client
.
NegotiateAsyncOps
();
...
...
@@ -29,11 +26,16 @@ namespace ExchangeService.GrpcServer
await
client
.
AddRequestAsync
(
requests
);
await
client
.
SendAsync
();
await
responseStream
.
WriteAsync
(
new
DicomFilesTransferResponse
()
{
Message
=
$"
{
request
.
UploadedFile
}
file Send"
});
Log
.
Information
(
$"
{
request
.
UploadedFile
}
file Send"
);
}
catch
(
Exception
ex
)
{
Log
.
Information
(
ex
.
Message
);
await
responseStream
.
WriteAsync
(
new
DicomFilesTransferResponse
()
{
Message
=
ex
.
Message
});
}
Log
.
Information
(
"DicomTransferFile Finished ...!"
);
}
}
}
ExchangeService.GrpcServer/Startup.cs
View file @
1d8619b3
...
...
@@ -2,11 +2,13 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
ExchangeService.GrpcServer.SerilogConfig
;
using
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
Serilog
;
namespace
ExchangeService.GrpcServer
{
...
...
@@ -38,6 +40,18 @@ namespace ExchangeService.GrpcServer
await
context
.
Response
.
WriteAsync
(
"Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"
);
});
});
var
resp
=
SeriLogConfig
.
LoggerConfiguration
(
Serilog
.
Events
.
LogEventLevel
.
Debug
);
if
(!
resp
.
Result
)
{
Console
.
WriteLine
(
resp
.
Log
);
return
;
}
SeriLogConfig
.
LoggerConfiguration
(
Serilog
.
Events
.
LogEventLevel
.
Information
);
Log
.
Information
(
"Starting ExchangeService.GrpcServer ..."
);
}
}
}
ExchangeService.Test/DicomFileTransferServerTests.cs
View file @
1d8619b3
...
...
@@ -15,7 +15,7 @@ namespace ExchangeServiceGrpcServer.Test
{
// Arrange
var
service
=
new
DicomFileOperationService
(
NullLoggerFactory
.
Instance
);
var
service
=
new
DicomFileOperationService
();
string
uploadedFile
=
"D:\\Study\\0095.07.24\\Anonymized (2)\\SR 1\\IM00001.dcm"
;
var
cts
=
new
CancellationTokenSource
();
var
callContext
=
TestServerCallContext
.
Create
(
cancellationToken
:
cts
.
Token
);
...
...
@@ -34,7 +34,7 @@ namespace ExchangeServiceGrpcServer.Test
{
// Arrange
var
service
=
new
DicomFileOperationService
(
NullLoggerFactory
.
Instance
);
var
service
=
new
DicomFileOperationService
();
List
<
string
>
uploadedFiles
=
new
List
<
string
>()
{
"D:\\Study\\0095.07.24\\Anonymized (2)\\SR 1\\IM00001.dcm"
,
...
...
@@ -62,7 +62,7 @@ namespace ExchangeServiceGrpcServer.Test
{
// Arrange
var
service
=
new
DicomFileOperationService
(
NullLoggerFactory
.
Instance
);
var
service
=
new
DicomFileOperationService
();
List
<
string
>
uploadedFiles
=
new
List
<
string
>()
{
"D:\\Study\\0095.07.24\\Anonymized (2)\\SR 1\\IM00001.dcm"
,
...
...
@@ -98,7 +98,7 @@ namespace ExchangeServiceGrpcServer.Test
{
// Arrange
var
service
=
new
DicomFileOperationService
(
NullLoggerFactory
.
Instance
);
var
service
=
new
DicomFileOperationService
();
string
uploadedFile
=
"D:\\Study\\0095.07.24\\Anonymized (2)\\SR 1\\IM900001.dcm"
;
var
cts
=
new
CancellationTokenSource
();
var
callContext
=
TestServerCallContext
.
Create
(
cancellationToken
:
cts
.
Token
);
...
...
@@ -117,7 +117,7 @@ namespace ExchangeServiceGrpcServer.Test
{
// Arrange
var
service
=
new
DicomFileOperationService
(
NullLoggerFactory
.
Instance
);
var
service
=
new
DicomFileOperationService
();
var
cts
=
new
CancellationTokenSource
();
var
callContext
=
TestServerCallContext
.
Create
(
cancellationToken
:
cts
.
Token
);
var
responseStream
=
new
TestServerStreamWriter
<
DicomFilesTransferResponse
>(
callContext
);
...
...
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