10 | Swapping to Development environment will display more detailed information about the error that occurred.
11 |
12 |
13 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.
14 |
15 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:17408/",
7 | "sslPort": 0
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "Linux": "Linux",
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "NetCoreWebApp": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "launchUrl": "http://localhost:5000",
23 | "environmentVariables": {
24 | "ASPNETCORE_ENVIRONMENT": "Development"
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/Properties/PublishProfiles/publish-publish.ps1:
--------------------------------------------------------------------------------
1 | [cmdletbinding(SupportsShouldProcess=$true)]
2 | param($publishProperties=@{}, $packOutput, $pubProfilePath)
3 |
4 | # to learn more about this file visit https://go.microsoft.com/fwlink/?LinkId=524327
5 |
6 | try{
7 | if ($publishProperties['ProjectGuid'] -eq $null){
8 | $publishProperties['ProjectGuid'] = '61604e42-0cdb-4b8a-82e1-32a8c87db979'
9 | }
10 |
11 | $publishModulePath = Join-Path (Split-Path $MyInvocation.MyCommand.Path) 'publish-module.psm1'
12 | Import-Module $publishModulePath -DisableNameChecking -Force
13 |
14 | # call Publish-AspNet to perform the publish operation
15 | Publish-AspNet -publishProperties $publishProperties -packOutput $packOutput -pubProfilePath $pubProfilePath
16 | }
17 | catch{
18 | "An error occurred during publish.`n{0}" -f $_.Exception.Message | Write-Error
19 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 50px;
3 | padding-bottom: 20px;
4 | }
5 |
6 | /* Wrapping element */
7 | /* Set some basic padding to keep content from hitting the edges */
8 | .body-content {
9 | padding-left: 15px;
10 | padding-right: 15px;
11 | }
12 |
13 | /* Set widths on the form inputs since otherwise they're 100% wide */
14 | input,
15 | select,
16 | textarea {
17 | max-width: 280px;
18 | }
19 |
20 | /* Carousel */
21 | .carousel-caption p {
22 | font-size: 20px;
23 | line-height: 1.4;
24 | }
25 |
26 | /* Make .svg files in the carousel display properly in older browsers */
27 | .carousel-inner .item img[src$=".svg"]
28 | {
29 | width: 100%;
30 | }
31 |
32 | /* Hide/rearrange for smaller screens */
33 | @media screen and (max-width: 767px) {
34 | /* Hide captions */
35 | .carousel-caption {
36 | display: none
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/MQ/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("MQ")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("e666614b-728c-48bf-a535-4b519a9a3459")]
20 |
--------------------------------------------------------------------------------
/src/MQClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("MQClient")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("c6425af8-d448-4731-8f9e-c876bddfbc39")]
20 |
--------------------------------------------------------------------------------
/src/MSServer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("MSServer")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("b6730ac2-8bda-4d01-b5ce-0b3222cd615d")]
20 |
--------------------------------------------------------------------------------
/src/NetCoreApp.Logger.File/FileLoggerExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.IO;
6 | using Microsoft.Extensions.Configuration;
7 | using NetCoreApp.Logger.File;
8 |
9 | namespace Microsoft.Extensions.Logging
10 | {
11 | public static class FileLoggerExtensions
12 | {
13 | //add 日志文件创建规则,分割规则,格式化规则,过滤规则 to appsettings.json
14 | public static ILoggerFactory AddFile(this ILoggerFactory factory, IConfiguration configuration)
15 | {
16 | return AddFile(factory, new FileLoggerSettings(configuration));
17 | }
18 | public static ILoggerFactory AddFile(this ILoggerFactory factory, FileLoggerSettings fileLoggerSettings)
19 | {
20 | factory.AddProvider(new FileLoggerProvider(fileLoggerSettings));
21 | return factory;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/Properties/PublishProfiles/publish.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | FileSystem
9 | Release
10 | Any CPU
11 |
12 | True
13 | False
14 | netcoreapp1.0
15 | True
16 | .\bin\PublishOutput
17 | False
18 |
19 |
--------------------------------------------------------------------------------
/src/NetCoreApp.Logger.File/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyConfiguration("")]
9 | [assembly: AssemblyCompany("")]
10 | [assembly: AssemblyProduct("NetCoreApp.Logger.File")]
11 | [assembly: AssemblyTrademark("")]
12 |
13 | // Setting ComVisible to false makes the types in this assembly not visible
14 | // to COM components. If you need to access a type in this assembly from
15 | // COM, set the ComVisible attribute to true on that type.
16 | [assembly: ComVisible(false)]
17 |
18 | // The following GUID is for the ID of the typelib if this project is exposed to COM
19 | [assembly: Guid("03616715-5482-4f5c-921b-a4dda9793ddc")]
20 |
--------------------------------------------------------------------------------
/src/MQClient/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | //写本地log文件
3 | //已创建logger的categoryName区分配置。可配置多规则多文件写入
4 | "FileLogging": {
5 | // 相对路径:log:current path+'\log'
6 | // 绝对路径:C://log
7 | // linux 绝对路径:/var/log/netcorewebapp
8 | //多环境部署,可以使用环境变量配置文件方式。
9 | "DefaultPath": "log", //默认文件地址
10 | "DefaultMaxMB": 500, //默认最大文件大小
11 | "DefaultFileName": "yyyyMMdd", //默认文件名字
12 | "DefaultRollingType": "Day", //默认文件新建方式
13 | //过滤器,以.分割,逐层匹配
14 | "LogLevel": {
15 | "Default": "Debug",
16 | "System": "Information",
17 | "Microsoft": "Information",
18 | "NetCoreWebApp": "Debug",
19 | "Test.NewFile": "Debug"
20 | },
21 | //log需要写入的文件。
22 | "Path": {
23 | "Test.NewFile": "log/secfile"
24 | },
25 | //log名字
26 | "FileName": {
27 | "Test.NewFile": "yyyyMMddHH"
28 | },
29 | //文件新建方式,未实现
30 | "RollingType": {
31 | "Test.NewFile": "Minute"
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace NetCoreWebApp
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 |
17 | //args
18 | //dotnet NetCoreWebApp.dll --server.urls="http://localhost:5000/;http://localhost:5001/"
19 | var config = new ConfigurationBuilder()
20 | .AddCommandLine(args)
21 | .Build();
22 |
23 | var host = new WebHostBuilder()
24 | .UseConfiguration(config)
25 | .UseKestrel()
26 | .UseContentRoot(Directory.GetCurrentDirectory())
27 | .UseIISIntegration()
28 | .UseStartup()
29 | .Build();
30 |
31 | host.Run();
32 |
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/lib/jquery-validation/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation",
3 | "homepage": "http://jqueryvalidation.org/",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/jzaefferer/jquery-validation.git"
7 | },
8 | "authors": [
9 | "Jörn Zaefferer "
10 | ],
11 | "description": "Form validation made easy",
12 | "main": "dist/jquery.validate.js",
13 | "keywords": [
14 | "forms",
15 | "validation",
16 | "validate"
17 | ],
18 | "license": "MIT",
19 | "ignore": [
20 | "**/.*",
21 | "node_modules",
22 | "bower_components",
23 | "test",
24 | "demo",
25 | "lib"
26 | ],
27 | "dependencies": {
28 | "jquery": ">= 1.7.2"
29 | },
30 | "version": "1.14.0",
31 | "_release": "1.14.0",
32 | "_resolution": {
33 | "type": "version",
34 | "tag": "1.14.0",
35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48"
36 | },
37 | "_source": "git://github.com/jzaefferer/jquery-validation.git",
38 | "_target": ">=1.8",
39 | "_originalSource": "jquery-validation"
40 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/lib/bootstrap/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap",
3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
4 | "keywords": [
5 | "css",
6 | "js",
7 | "less",
8 | "mobile-first",
9 | "responsive",
10 | "front-end",
11 | "framework",
12 | "web"
13 | ],
14 | "homepage": "http://getbootstrap.com",
15 | "license": "MIT",
16 | "moduleType": "globals",
17 | "main": [
18 | "less/bootstrap.less",
19 | "dist/js/bootstrap.js"
20 | ],
21 | "ignore": [
22 | "/.*",
23 | "_config.yml",
24 | "CNAME",
25 | "composer.json",
26 | "CONTRIBUTING.md",
27 | "docs",
28 | "js/tests",
29 | "test-infra"
30 | ],
31 | "dependencies": {
32 | "jquery": "1.9.1 - 2"
33 | },
34 | "version": "3.3.6",
35 | "_release": "3.3.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.3.6",
39 | "commit": "81df608a40bf0629a1dc08e584849bb1e43e0b7a"
40 | },
41 | "_source": "git://github.com/twbs/bootstrap.git",
42 | "_target": "3.3.6",
43 | "_originalSource": "bootstrap"
44 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2015 Twitter, Inc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/MQ/MQ.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | e666614b-728c-48bf-a535-4b519a9a3459
11 | MQ
12 | .\obj
13 | .\bin\
14 | v4.6.1
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/MQClient/MQClient.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | c6425af8-d448-4731-8f9e-c876bddfbc39
11 | MQClient
12 | .\obj
13 | .\bin\
14 | v4.6.1
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/MSServer/MSServer.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | b6730ac2-8bda-4d01-b5ce-0b3222cd615d
11 | MSServer
12 | .\obj
13 | .\bin\
14 | v4.6.1
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/NetCoreApp.Logger.File/NetCoreApp.Logger.File.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 |
10 | 03616715-5482-4f5c-921b-a4dda9793ddc
11 | NetCoreApp.Logger.File
12 | .\obj
13 | .\bin\
14 | v4.6.1
15 |
16 |
17 |
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/MQClient/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0-*",
3 | "buildOptions": {
4 | "emitEntryPoint": true,
5 | "copyToOutput": [ "mqsettings.json", "appsettings.json" ]
6 | },
7 | "publishOptions": {
8 | "include": [ "mqsettings.json", "appsettings.json" ]
9 | },
10 | "dependencies": {
11 | "Autofac": "4.2.1",
12 | "CoreCompat.Microsoft.Practices.ServiceLocation": "1.3.0-r2",
13 | "Microsoft.EntityFrameworkCore": "1.1.0",
14 | "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
15 | "Microsoft.Extensions.Configuration": "1.1.0",
16 | "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
17 | "Microsoft.Extensions.Configuration.Json": "1.1.0",
18 | "Microsoft.Extensions.DependencyInjection": "1.1.0",
19 | "Microsoft.Extensions.Logging": "1.1.0",
20 | "Microsoft.Extensions.Logging.Console": "1.1.0",
21 | "Microsoft.Extensions.Logging.Debug": "1.1.0",
22 | "Microsoft.NETCore.App": {
23 | "type": "platform",
24 | "version": "1.1.0"
25 | },
26 | "MQ": "1.0.0-*",
27 | "NetCoreApp.Logger.File": "1.0.0-*",
28 | "RabbitMQ.Client": "4.1.1",
29 | "System.Text.Encoding": "4.3.0",
30 | "System.Text.Encoding.CodePages": "4.3.0"
31 | },
32 | "frameworks": {
33 | "netcoreapp1.0": {
34 | "imports": "dnxcore50"
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/lib/jquery-validation-unobtrusive/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation-unobtrusive",
3 | "version": "3.2.6",
4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive",
5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.",
6 | "main": [
7 | "jquery.validate.unobtrusive.js"
8 | ],
9 | "ignore": [
10 | "**/.*",
11 | "*.json",
12 | "*.md",
13 | "*.txt",
14 | "gulpfile.js"
15 | ],
16 | "keywords": [
17 | "jquery",
18 | "asp.net",
19 | "mvc",
20 | "validation",
21 | "unobtrusive"
22 | ],
23 | "authors": [
24 | "Microsoft"
25 | ],
26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm",
27 | "repository": {
28 | "type": "git",
29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git"
30 | },
31 | "dependencies": {
32 | "jquery-validation": ">=1.8",
33 | "jquery": ">=1.8"
34 | },
35 | "_release": "3.2.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.2.6",
39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7"
40 | },
41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git",
42 | "_target": "3.2.6",
43 | "_originalSource": "jquery-validation-unobtrusive"
44 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/NetCoreWebApp.xproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 14.0
5 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
6 |
7 |
8 |
9 | 61604e42-0cdb-4b8a-82e1-32a8c87db979
10 | NetCoreWebApp
11 | .\obj
12 | .\bin\
13 | v4.6.1
14 |
15 |
16 | 2.0
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ApplicationInsights": {
3 | "InstrumentationKey": ""
4 | },
5 | "ConnectionStrings": {
6 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-NetCoreWebApp-166558c2-5cd2-4df4-a8cb-b9e4d17c55b1;Trusted_Connection=True;MultipleActiveResultSets=true"
7 | },
8 | //测试ioc注入自定义配置
9 | "IndexSetting": {
10 | "Title": "Title...........",
11 | "Desc": "Desc............"
12 | },
13 | "Logging": {
14 | "IncludeScopes": true,
15 | "LogLevel": {
16 | "Default": "Debug",
17 | "System": "Information",
18 | "Microsoft": "Information"
19 | }
20 | },
21 | //写本地log文件
22 | //已创建logger的categoryName区分配置。可配置多规则多文件写入
23 | "FileLogging": {
24 | // 相对路径:log:current path+'\log'
25 | // 绝对路径:C://log
26 | // linux 绝对路径:/var/log/netcorewebapp
27 | //多环境部署,可以使用环境变量配置文件方式。
28 | "DefaultPath": "log", //默认文件地址
29 | "DefaultMaxMB": 500, //默认最大文件大小
30 | "DefaultFileName": "yyyyMMdd", //默认文件名字
31 | "DefaultRollingType": "Day", //默认文件新建方式
32 | //过滤器,以.分割,逐层匹配
33 | "LogLevel": {
34 | "Default": "Debug",
35 | "System": "Information",
36 | "Microsoft": "Information",
37 | "NetCoreWebApp": "Debug",
38 | "Test.NewFile": "Debug"
39 | },
40 | //log需要写入的文件。
41 | "Path": {
42 | "Test.NewFile": "log/secfile"
43 | },
44 | //log名字
45 | "FileName": {
46 | "Test.NewFile": "yyyyMMddHH"
47 | },
48 | //文件新建方式,未实现
49 | "RollingType": {
50 | "Test.NewFile": "Minute"
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": ".NET Core Launch (console)",
6 | "type": "coreclr",
7 | "request": "launch",
8 | "preLaunchTask": "build",
9 | "program": "${workspaceRoot}/bin/Debug//",
10 | "args": [],
11 | "cwd": "${workspaceRoot}",
12 | "stopAtEntry": false,
13 | "externalConsole": false
14 | },
15 | {
16 | "name": ".NET Core Launch (web)",
17 | "type": "coreclr",
18 | "request": "launch",
19 | "preLaunchTask": "build",
20 | "program": "${workspaceRoot}/bin/Debug//",
21 | "args": [],
22 | "cwd": "${workspaceRoot}",
23 | "stopAtEntry": false,
24 | "launchBrowser": {
25 | "enabled": true,
26 | "args": "${auto-detect-url}",
27 | "windows": {
28 | "command": "cmd.exe",
29 | "args": "/C start ${auto-detect-url}"
30 | },
31 | "osx": {
32 | "command": "open"
33 | },
34 | "linux": {
35 | "command": "xdg-open"
36 | }
37 | },
38 | "env": {
39 | "ASPNETCORE_ENVIRONMENT": "Development"
40 | }
41 | },
42 | {
43 | "name": ".NET Core Attach",
44 | "type": "coreclr",
45 | "request": "attach",
46 | "processId": 0
47 | }
48 | ]
49 | }
--------------------------------------------------------------------------------
/src/NetCoreWebApp/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright jQuery Foundation and other contributors, https://jquery.org/
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/jquery/jquery
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | All files located in the node_modules and external directories are
34 | externally maintained libraries used by this software which have their
35 | own licenses; we recommend you read them, as their terms may differ from
36 | the terms above.
37 |
--------------------------------------------------------------------------------
/src/MSServer/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using MQ;
7 |
8 | namespace MSServer
9 | {
10 | public class Program
11 | {
12 | public static void Main(string[] args)
13 | {
14 | //var factory = new RabbitMQ.Client.ConnectionFactory();
15 | //factory.HostName = "192.168.50.2";
16 | //factory.UserName = "user";
17 | //factory.Password = "user";
18 | //factory.VirtualHost = "/";
19 |
20 | //using (var connection = factory.CreateConnection())
21 | //{
22 | // using (var channel = connection.CreateModel())
23 | // {
24 | // //channel.ExchangeDeclare("ext1", "direct", true, false, null);
25 | // //channel.QueueDeclare("queue_1", true, false, false, null);
26 | // //channel.QueueBind("queue_1", "ext1", "route", null);
27 |
28 | // var prop = channel.CreateBasicProperties();
29 | // prop.DeliveryMode = 2;
30 | // prop.Headers = new Dictionary();
31 | // prop.Headers["msgid"] = Guid.NewGuid().ToString("N");
32 | // var t = true;
33 | // int i = 0;
34 | // while (true)
35 | // {
36 | // i++;
37 | // channel.BasicPublish("amq.topic", ((t = !t) ? "route" : "route.a"),
38 | // true, prop, Encoding.UTF8.GetBytes(DateTime.Now.ToString()));
39 | // }
40 | // }
41 | //}
42 |
43 | for (int i = 0; i < 100; i++)
44 | {
45 | //EventBus.Publish("amq.topic", "PPP", "", DateTime.Now);
46 | EventBus.Publish("productid","guangbo", "", "", DateTime.Now);
47 | }
48 |
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "Microsoft.AspNetCore.Razor.Tools": {
4 | "version": "1.0.0-preview2-final",
5 | "type": "build"
6 | },
7 | "NetCoreApp.Logger.File": "1.0.0-*",
8 | "Autofac.Extensions.DependencyInjection": "4.0.0",
9 | "BundlerMinifier.Core": "2.2.306",
10 | "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
11 | "Microsoft.AspNetCore.Diagnostics": "1.1.0",
12 | "Microsoft.AspNetCore.Mvc": "1.1.0",
13 | "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
14 | "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
15 | "Microsoft.AspNetCore.StaticFiles": "1.1.0",
16 | "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
17 | "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
18 | "Microsoft.Extensions.Configuration.Json": "1.1.0",
19 | "Microsoft.Extensions.Logging": "1.1.0",
20 | "Microsoft.Extensions.Logging.Console": "1.1.0",
21 | "Microsoft.Extensions.Logging.Debug": "1.1.0",
22 | "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
23 | "Microsoft.NETCore.App": {
24 | "type": "platform",
25 | "version": "1.1.0"
26 | },
27 | "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
28 | "System.Text.Encoding.CodePages": "4.3.0"
29 | },
30 |
31 | "tools": {
32 | "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
33 | "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
34 | },
35 |
36 | "frameworks": {
37 | "netcoreapp1.0": {
38 | "imports": [
39 | "dotnet5.6",
40 | "portable-net45+win8"
41 | ]
42 | }
43 | },
44 |
45 | "buildOptions": {
46 | "emitEntryPoint": true,
47 | "preserveCompilationContext": true
48 | },
49 |
50 | "runtimeOptions": {
51 | "configProperties": {
52 | "System.GC.Server": true
53 | }
54 | },
55 |
56 | "publishOptions": {
57 | "include": [
58 | "wwwroot",
59 | "Views",
60 | "Areas/**/Views",
61 | "appsettings.json",
62 | "web.config"
63 | ]
64 | },
65 |
66 | "scripts": {
67 | "prepublish": [ "bower install", "dotnet bundle" ],
68 | "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/MQ/Internal/EventBusSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.Logging;
7 | using Microsoft.Extensions.Options;
8 | using Microsoft.Extensions.Primitives;
9 |
10 | namespace MQ.Internal
11 | {
12 | public class EventBusSettings
13 | {
14 | IConfiguration _configuration;
15 | public IChangeToken ChangeToken { get; private set; }
16 | ILogger _logger;
17 | public EventBusSettings(IConfiguration configuration, ILogger logger)
18 | {
19 | _configuration = configuration;
20 | this.ChangeToken = _configuration.GetReloadToken();
21 | _logger = logger;
22 |
23 |
24 | List hostsOptions = new List();
25 | ConfigurationBinder.Bind(_configuration.GetSection("Hosts"), hostsOptions);
26 | this.Hosts = hostsOptions.ToDictionary(p => p.Name, p => p);
27 |
28 | List productOptions = new List();
29 | ConfigurationBinder.Bind(_configuration.GetSection("Products"), productOptions);
30 | this.Products = productOptions.ToDictionary(p => p.Id, p => p);
31 |
32 | _logger.LogInformation("init EventBus.Hosts:" + this.Hosts.ToJson());
33 | _logger.LogInformation("init EventBus.Products:" + this.Products.ToJson());
34 | }
35 |
36 |
37 | public Dictionary Hosts { get; set; }
38 | public Dictionary Products { get; set; }
39 |
40 | }
41 |
42 | public class EventBusHostOptions
43 | {
44 | public string Name { get; set; } = "default";
45 | public string Address { get; set; }
46 | public string UserName { get; set; } = "guest";
47 | public string UserPassword { get; set; } = "guest";
48 | public string Port { get; set; } = "5672";
49 | public string VHost { get; set; } = "/";
50 | public int Heartbeat { get; set; } = 60;
51 | public bool AutoRecovery { get; set; } = true;
52 | }
53 |
54 | public class ProductOptions
55 | {
56 | public string Id { get; set; }
57 | public string Host { get; set; } = "default";
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/src/MQClient/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Microsoft.EntityFrameworkCore;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.DependencyInjection;
10 | using Microsoft.Extensions.Logging;
11 | using Microsoft.Practices.ServiceLocation;
12 | using MQ;
13 | using MQ.Internal;
14 | using RabbitMQ.Client;
15 | using RabbitMQ.Client.Content;
16 | using RabbitMQ.Client.Events;
17 |
18 | namespace MQClient
19 | {
20 | public class Program
21 | {
22 | static IServiceProvider sp;
23 |
24 | public static void Main(string[] args)
25 | {
26 | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
27 |
28 | var appsettings = new ConfigurationBuilder()
29 | .SetBasePath(System.IO.Directory.GetCurrentDirectory())
30 | .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
31 |
32 | var mqsettings = new ConfigurationBuilder()
33 | .SetBasePath(System.IO.Directory.GetCurrentDirectory())
34 | .AddJsonFile("mqsettings.json", optional: true, reloadOnChange: true).Build();
35 |
36 | //----------------------------------------------------------------------------------------
37 |
38 |
39 | ServiceCollection sc = new ServiceCollection();
40 | sc.AddLogging();
41 |
42 | sc.AddDbContext(ServiceLifetime.Transient);
43 |
44 | sp = sc.BuildServiceProvider();
45 | //----------------------------------------------------------------------------------------
46 |
47 | sp.GetService()
48 | .AddConsole()
49 | .AddDebug()
50 | .AddFile(appsettings.GetSection("FileLogging"));
51 |
52 | EventBus.Configure(mqsettings, sp);
53 |
54 | //主题发布订阅
55 | EventBus.Subscribe("produtid", "queue_3", time =>
56 | {
57 | //Console.WriteLine(time);
58 | return true;
59 | });
60 |
61 |
62 | //广播方式
63 | EventBus.Subscribe("produt", "guangbo", message =>
64 | {
65 | Console.WriteLine(message);
66 | return true;
67 | }, new SubscribeOptions() { Model = MessageModel.Broadcasting });
68 |
69 | EventBus.Subscribe("produt", "queue_1", message =>
70 | {
71 | return true;
72 | });
73 |
74 |
75 | Console.WriteLine("开始监听");
76 | Console.ReadLine();
77 | EventBus.Exit();
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Logging;
8 | using Microsoft.Extensions.Options;
9 | using NetCoreWebApp.Models;
10 |
11 | namespace NetCoreWebApp.Controllers
12 | {
13 | public class HomeController : Controller
14 | {
15 |
16 | //1.构造函数注入
17 | IOptions _ser;
18 | public HomeController(IOptions ser)
19 | {
20 | this._ser = ser;
21 | }
22 | public IActionResult Index2([FromServices]IOptions ser/*2.FromServices方式注入*/)
23 | {
24 | //2.这种方式比较适合,service不是在整个controller里面使用的情况下。只有某个单独的action需要。可以考虑使用这种方式
25 | _ser = ser;
26 |
27 | //3.IServiceProvider。ioc容器直接获取。
28 | //3.官方并不推荐使用,官方原话
29 | //Generally, you shouldn’t use these properties directly,
30 | //preferring instead to request the types your classes you require via your class’s constructor,
31 | //and letting the framework inject these dependencies.
32 | //This yields classes that are easier to test (see Testing) and are more loosely coupled.
33 | //大意是不应该使用这种方式,而应该使用构造函数的方式注入。因为能够方便测试并且设计上更加解耦。
34 | _ser = this.HttpContext.RequestServices.GetService>();
35 | _ser.Value.Desc = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
36 | return View(ser.Value);
37 | }
38 |
39 | public IActionResult Index([FromServices]ILogger logger, [FromServices]ILoggerFactory factory)
40 | {
41 | logger.LogInformation("begin");
42 | using (logger.BeginScope("{0},{1}", "你是i", "SB!!"))
43 | {
44 | logger.LogError("error......................");
45 | logger.LogInformation("LogInformation......................");
46 | }
47 | logger.LogInformation("end");
48 |
49 |
50 | factory.CreateLogger("Test.NewFile").LogError("!!!!!!!!!!!!!!!!!!!!!!!!!");
51 |
52 | return this.Content(System.IO.Directory.GetCurrentDirectory());
53 | }
54 |
55 | public IActionResult About()
56 | {
57 | ViewData["Message"] = "Your application description page.";
58 |
59 | return View();
60 | }
61 |
62 | public IActionResult Contact()
63 | {
64 | ViewData["Message"] = "Your contact page.";
65 |
66 | return View();
67 | }
68 |
69 | public IActionResult Error()
70 | {
71 | return View();
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/NetCoreApp.Logger.File/FileLoggerSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.Logging;
7 | using Microsoft.Extensions.Primitives;
8 |
9 | namespace NetCoreApp.Logger.File
10 | {
11 | public class FileLoggerSettings
12 | {
13 | IConfiguration _configuration;
14 | public IChangeToken ChangeToken { get; private set; }
15 | public FileLoggerSettings(IConfiguration configuration)
16 | {
17 | _configuration = configuration;
18 | this.ChangeToken = _configuration.GetReloadToken();
19 | }
20 |
21 | public string DefaultPath
22 | {
23 | get
24 | {
25 | return this._configuration["DefaultPath"];
26 | }
27 | }
28 |
29 | public int DefaultMaxMB
30 | {
31 | get
32 | {
33 | return int.Parse(this._configuration["DefaultMaxMB"]);
34 | }
35 | }
36 | public string DefaultFileName
37 | {
38 | get { return this._configuration["DefaultFileName"]; }
39 | }
40 |
41 | public void Reload()
42 | {
43 | //update cache settings
44 | }
45 |
46 | public Tuple GetSwitch(string name)
47 | {
48 | var section = this._configuration.GetSection("LogLevel");
49 | if (section != null)
50 | {
51 | LogLevel level;
52 | if (Enum.TryParse(section[name], true, out level))
53 | return new Tuple(true, level);
54 | }
55 | return new Tuple(false, LogLevel.None);
56 | }
57 | public Tuple GetDiretoryPath(string name)
58 | {
59 | var section = this._configuration.GetSection("Path");
60 | if (section!=null)
61 | {
62 | var path = section[name];
63 | if (!String.IsNullOrEmpty(path))
64 | {
65 | return new Tuple(true, path);
66 | }
67 | }
68 | return new Tuple(false, this.DefaultPath);
69 | }
70 | public Tuple GetFileName(string name)
71 | {
72 | var section = this._configuration.GetSection("FileName");
73 | if (section != null)
74 | {
75 | var path = section[name];
76 | if (!String.IsNullOrEmpty(path))
77 | {
78 | return new Tuple(true, path);
79 | }
80 | }
81 | return new Tuple(false, this.DefaultFileName);
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/NetCoreWebApp/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @ViewData["Title"] - NetCoreWebApp
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 | @Html.ApplicationInsightsJavaScript(TelemetryConfiguration)
19 |
20 |
21 |