diff --git a/.gitignore b/.gitignore
index 3ddda332d..d9cef967a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -195,6 +195,7 @@ ClientBin/
*.pfx
*.publishsettings
node_modules/
+!/node_modules/swagger-ui-dist/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
@@ -262,3 +263,9 @@ paket-files/
__pycache__/
*.pyc
+/src/Surging.Core/Surging.Core.CPlatform/CPlatformResource.en-US.resources
+api/
+_site/
+
+/src/Surging.ApiGateway
+/src/Surging.Services/Surging.Services.Server/Dockerfile
diff --git a/samples/README.md b/FETCH_HEAD
similarity index 100%
rename from samples/README.md
rename to FETCH_HEAD
diff --git a/README.EN.md b/README.EN.md
index de4072624..95fc52d7d 100644
--- a/README.EN.md
+++ b/README.EN.md
@@ -4,7 +4,11 @@
# surging is a distributed micro service framework that provides high-performance RPC remote service calls, using Zookeeper, Consul as the registration center for surging services, integrating hash, random, polling as a load balancing algorithm, RPC integration using the netty framework, Using asynchronous transmission.
-Start configuration:
+### Architecture:
+
+
+
+### Start configuration:
diff --git a/README.md b/README.md
index 5574e670b..719aca3a9 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# surging [English](https://github.com/dotnetcore/surging/blob/master/README.EN.md)
[![Member project of .NET Core Community](https://img.shields.io/badge/member%20project%20of-NCC-9e20c9.svg)](https://github.com/dotnetcore)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://mit-license.org/)
-### surging 是一个分布式微服务框架,提供高性能RPC远程服务调用,采用Zookeeper、Consul作为surging服务的注册中心,集成了哈希,随机,轮询,压力最小优先作为负载均衡的算法,RPC集成采用的是netty框架,采用异步传输。
+### surging 是一个分布式微服务框架,提供高性能RPC远程服务调用,采用Zookeeper、Consul作为surging服务的注册中心,集成了哈希,随机,轮询,压力最小优先作为负载均衡的算法,RPC可以选择采用netty或thrift框架,采用异步非阻塞传输。
@@ -18,6 +18,11 @@
### 微服务定义
微服务应该是可以自由组合拆分,对于每个业务都是独立的,针对于业务模块的 CRUD 可以注册为服务,而每个服务都是高度自治的,从开发,部署都是独立,而每个服务只做单一功能,利用领域驱动设计去更好的拆分成粒度更小的模块
+### 微服务边界
+微服务是针对业务的松耦合,也是粒度最小的功能业务模块,针对于行业解决方案,集成相应的service host,而针对于业务需要一些中间件来辅助,比如缓存中间件,eventbus中间件(消息中间件),数据储存中间件,而各个服务又可以互相通过rpc进行可靠性通信。
+
+引擎是微服务的容器,而docker 是服务引擎的容器,而利用k8s或rancher可以针对docker集群化管理,可以服务编排弹性扩容,熟知工具,让工具物尽其用。
+
### 能做什么
1.简化的服务调用,通过服务规则的指定,就可以做到服务之间的远程调用,无需其它方式的侵入
@@ -39,9 +44,13 @@ docker hub : docker pull serviceengine/surging:版本号
nuget:Install-Package surging -Version 版本号
-### surging模块功能
+### 架构图
+
+
-
+### 调用链
+
+
### 配置:
@@ -262,11 +271,18 @@ Task.FromResult(new Surging.IModuleServices.Common.Models.UserModel
.AddClientIntercepted(typeof(CacheProviderInterceptor))
```
+## 捐赠明细
+
+surging 接受来自社区的捐赠,所有款项将通过 [捐赠明细表](Statement-of-Income-and-Expense.md) 进行公示,接受社区监督。
+
IDE:Visual Studio 2017 15.5,vscode
框架:.NET core 2.1
QQ群:615562965
-* [Demo](https://github.com/billyang/SurgingDemo)
* [文档](http://docs.dotnet-china.org/surging/)
* [简单示例](https://github.com/dotnetcore/surging/blob/master/docs/docs.en/INDEX.md)
+
+## 谁在使用
+
+
diff --git a/Statement-of-Income-and-Expense.md b/Statement-of-Income-and-Expense.md
new file mode 100644
index 000000000..2090bfa09
--- /dev/null
+++ b/Statement-of-Income-and-Expense.md
@@ -0,0 +1,64 @@
+# 收支明细表
+
+说明:为保证surging财务公开透明,决定将每一笔捐赠和支出记录于本表,资金由 [fanly](https://github.com/fanliang11) 托管,并且受社区人员监督用于surging的生态发展
+
+
+## 汇总
+
+截止到 2018 年 12 月 28 日:
++ 共获得捐赠 `49` 笔计 `8679.06` 元人民币
++ 暂无支出项
+
+## 明细
+
+| 序号 | 捐赠人 | 时间 | 金额 | 说明 | 留言 | 类型 |
+|------------|:------------:|-------------|--------------------|-------------------|--------------------|-----|
+| 1 | Murphy | 2018-12-19 | 100 | Murphy 个人捐赠 | 这家伙很懒 |获赠 |
+| 2 | 宗国 | 2018-12-19 | 20 | 宗国 个人捐赠 | 这家伙很懒 |获赠 |
+| 3 | 紫能 | 2018-12-19 | 50 | 紫能 个人捐赠 | 这家伙很懒 |获赠 |
+| 4 | Damon | 2018-12-19 | 18.8 | Damon 个人捐赠 | 支持一下 |获赠 |
+| 5 | 悉路 | 2018-12-19 | 10 | 悉路 个人捐赠 | 感谢作者的付出,希望能完善文档 |获赠 |
+| 6 | jiang | 2018-12-19 | 16.66 | jiang 个人捐赠 | 这家伙很懒 |获赠 |
+| 7 | 伯锰 z.l | 2018-12-19 | 20 | 伯锰 z.l 个人捐赠 | 期待1.0 |获赠 |
+| 8 | 匿名 | 2018-12-19 | 5000 | 匿名个人捐赠 | 这家伙很懒 |获赠 |
+| 9 | 爱吃牛排的牛仔 | 2018-12-19 | 66.66 | 爱吃牛排的牛仔个人捐赠 | 这家伙很懒 |获赠 |
+| 10 | siyue | 2018-12-20 | 50 | siyue个人捐赠 | 这家伙很懒 |获赠 |
+| 11 | 学飞 | 2018-12-20 | 200 | 学飞个人捐赠 | 还在学习,期待surging越来越好 |获赠 |
+| 12 | 昵称bai | 2018-12-21 | 10 | 昵称bai个人捐赠 | 这家伙很懒 |获赠 |
+| 13 | 半碗的彩霞 | 2018-12-21 | 10 | 半碗的彩霞个人捐赠 | 这家伙很懒 |获赠 |
+| 14 | 虎牙 | 2018-12-21 | 1000 | 虎牙个人捐赠 | 这家伙很懒 |获赠 |
+| 15 | 寸草无心 | 2018-12-21 | 100 | 寸草无心个人捐赠 | 关注surging已有大半年了 默默支持 |获赠 |
+| 16 | 洋 | 2018-12-24 | 1 | 洋个人捐赠 | dotnetty支持websocket了 |获赠 |
+| 17 | 高文 | 2018-12-24 | 10 | 高文个人捐赠 | 庆祝1.0 |获赠 |
+| 18 | 培根 | 2018-12-24 | 36 | 培根个人捐赠 | 捐赠一杯咖啡 |获赠 |
+| 19 | gesneriana | 2018-12-24 | 26 | gesneriana个人捐赠 | 这家伙很懒 |获赠 |
+| 20 | 学军 | 2018-12-27 | 100 | 学军个人捐赠 | 这家伙很懒 |获赠 |
+| 21 | 高立哲 | 2018-12-27 | 30 | 高立哲个人捐赠 | 这家伙很懒 |获赠 |
+| 22 | 俊文 | 2018-12-27 | 10 | 俊文个人捐赠 | 这家伙很懒 |获赠 |
+| 23 | 根堂 | 2018-12-28 | 100 | 根堂个人捐赠 | 这家伙很懒 |获赠 |
+| 24 | 东周 | 2018-12-28 | 5 | 东周个人捐赠 | 辛苦 |获赠 |
+| 25 | 纯 | 2018-12-28 | 20 | 纯个人捐赠 | 这家伙很懒 |获赠 |
+| 26 | 夏志行 | 2018-12-28 | 88 | 夏志行个人捐赠 | 这家伙很懒 |获赠 |
+| 27 | 勇 | 2018-12-28 | 88.88 | 勇个人捐赠 | 这家伙很懒 |获赠 |
+| 28 | 启旺 | 2018-12-28 | 10 | 勇个人捐赠 | 这家伙很懒 |获赠 |
+| 29 | 雯昌 | 2018-12-28 | 20 | 雯昌个人捐赠 | 支持surging |获赠 |
+| 30 | 宏伟 | 2018-12-28 | 500 | 宏伟个人捐赠 | 这家伙很懒 |获赠 |
+| 31 | 伟 | 2018-12-28 | 20 | 伟个人捐赠 | 这家伙很懒 |获赠 |
+| 32 | 建 | 2018-12-28 | 10 |建个人捐赠 | 希望大佬搞好文档,在下尽点微薄之力 |获赠 |
+| 33 | 林 | 2018-12-29 | 30 |林个人捐赠 | 这家伙很懒 |获赠 |
+| 34 | 俊强 | 2018-12-29 | 100 | 俊强个人捐赠 | 这家伙很懒 |获赠 |
+| 35 | 彪 | 2018-01-02 | 10 | 彪个人捐赠 | 支持一下surging |获赠 |
+| 36 | 忠全 | 2018-01-02 | 200 | 忠全个人捐赠 | 学习一下 |获赠 |
+| 37 | 思恒 | 2018-01-03 | 10 | 思恒个人捐赠 | 这家伙很懒 |获赠 |
+| 38 | 松波 | 2018-01-04 | 100 | 松波个人捐赠 | 出精品 |获赠 |
+| 39 | 先鸿 | 2019-01-05 | 30 | 先鸿个人捐赠 | 加油 |获赠 |
+| 40 | 杨坚 | 2019-01-08 | 100 | 杨坚个人捐赠 | 加油,希望surging能形成自己的社区 |获赠 |
+| 41 | 济良 | 2019-01-09 | 10 | 济良个人捐赠 | 这家伙很懒 |获赠 |
+| 42 | 祥 | 2019-01-11 | 36 | 祥个人捐赠 | 支持大佬,希望.net社区越来越好 |获赠 |
+| 43 | 文斌 | 2019-01-14 | 50 | 文斌个人捐赠 | 读书也要交学费,买书起码花点钱 |获赠 |
+| 44 | 笋 | 2019-01-25 | 30 | 笋个人捐赠 | 支持一下 |获赠 |
+| 45 | Leo | 2019-01-30 | 100 | Leo个人捐赠 | 支持surging |获赠 |
+| 46 | 文丽 | 2019-02-01 | 20 | 文丽 | 这家伙很懒 |获赠 |
+| 47 | 卫东 | 2019-02-13 | 16 | 卫东 | 这家伙很懒 |获赠 |
+| 48 | 安平 | 2019-02-15 | 30 | 安平 | 支持surging,感谢作者付出. |获赠 |
+| 49 | MyDAL | 2019-02-19 | 6.66 | MyDAL | 支持国人自己的轮子. |获赠 |
diff --git a/docfx.json b/docfx.json
new file mode 100644
index 000000000..b436d8477
--- /dev/null
+++ b/docfx.json
@@ -0,0 +1,83 @@
+{
+ "metadata": [
+ ],
+ "build": {
+ "content": [
+ {
+ "files": [
+ "docs/**.md",
+ "docs/**/toc.yml",
+ "toc.yml",
+ "*.md"
+ ]
+ }
+ ],
+ "resource": [
+ {
+ "files": [
+ "**/images/**"
+ ]
+ }
+ ],
+ "overwrite": [
+ {
+ "files": [
+ "apidoc/**.md"
+ ],
+ "exclude": [
+ "obj/**",
+ "_site/**"
+ ]
+ }
+ ],
+ "dest": "_site",
+ "globalMetadataFiles": [],
+ "fileMetadataFiles": [],
+ "template": [
+ "default"
+ ],
+ "postProcessors": [],
+ "markdownEngineName": "markdig",
+ "noLangKeyword": false,
+ "keepFileLink": false,
+ "cleanupCacheHistory": false,
+ "disableGitFeatures": false
+ }
+// "pdf": {
+// "content": [
+// {
+// "files": [
+// "docs/**.md",
+// "docs/**/toc.yml",
+// "toc.yml",
+// "*.md"
+// ]
+// }
+// ],
+// "resource": [
+// {
+// "files": [
+// "**/images/**"
+// ],
+// "exclude": [
+// "**/bin/**",
+// "**/obj/**",
+// "_site_pdf/**"
+// ]
+// }
+// ],
+// "overwrite": [
+// {
+// "files": [
+// "apidoc/**.md"
+// ],
+// "exclude": [
+// "**/bin/**",
+// "**/obj/**",
+// "_site_pdf/**"
+// ]
+// }
+// ],
+// "dest": "_site_pdf"
+// }
+}
\ No newline at end of file
diff --git a/docs/Architecture.png b/docs/Architecture.png
new file mode 100644
index 000000000..af1d6e577
Binary files /dev/null and b/docs/Architecture.png differ
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
new file mode 100644
index 000000000..581bdf7eb
--- /dev/null
+++ b/docs/CONTRIBUTING.md
@@ -0,0 +1,45 @@
+# Surging文档贡献指南
+
+## docfx的安装与使用
+### 1. 打开`powershell`,使用如下命令安装[Chocolatey](https://chocolatey.org/install)
+```shell
+Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
+```
+
+### 2. 安装`docfx`工具
+```shell
+choco install docfx -y
+```
+> **Notes**
+> - 安装完`docfx`之后需要重启`powershell`,才会有`docfx`命令
+
+### 3. `docfx`的使用
+```shell
+# 构建文档
+docfx build
+
+# 构建文档同时本地预览
+docfx build -s
+
+# 本地预览文档
+docfx serve
+```
+> **Notes**
+> - 更多关于`docfx`工具使用教程的请[参考](https://dotnet.github.io/docfx/tutorial/docfx.exe_user_manual.html)
+
+## 如何成为开发者文档贡献者
+我们欢迎所有有能力的开发者为surging社区做出自己的贡献,为surging的发展贡献自己的力量。您可以通过qq群或是issues向作者申请成为文档作者。我们会将文档的贡献者显示在开发者文档相关页面,对所有做出贡献的开发者表示感谢。
+
+## 编写开发者文档
+
+### 1. 新增文档目录
+在[`./docs/toc.yml`](./toc.yml)新增文档目录,并在首页[`./docs/index.md`](./index.md)中创建相关的链接。
+
+### 2. 编写开发者文档
+使用`markdown`编写开发者文档,将文档存放到相关模块的目录下。关于文档写作规范请[参考](https://github.com/ruanyf/document-style-guide)。
+
+### 3. 提交并发起PR
+发起pr后,经作者审核通过,将会合并到主分支。
+
+## 投稿
+欢迎开发者向社区投稿关于surging或是微服务相关的博客,您可以选择同时发表到其他平台,但是必须是原创的。请将相关的博文存放在`./docs/blogs`目录下,并向社区提交`PR`。
diff --git a/docs/blogs/index.md b/docs/blogs/index.md
new file mode 100644
index 000000000..2e88b4546
--- /dev/null
+++ b/docs/blogs/index.md
@@ -0,0 +1,3 @@
+# Surging相关博文
+
+## 欢迎投稿
\ No newline at end of file
diff --git a/docs/call-chain.png b/docs/call-chain.png
new file mode 100644
index 000000000..aeb496f01
Binary files /dev/null and b/docs/call-chain.png differ
diff --git a/docs/docs.cn/INDEX.md b/docs/docs.cn/INDEX.md
index b9adf8f4e..14d681c63 100644
--- a/docs/docs.cn/INDEX.md
+++ b/docs/docs.cn/INDEX.md
@@ -1,3 +1,40 @@
-surging is a high-performance microservice framework based on the .NET core language,It was created by an individual and designed for use in the cloud,
-Then add to dotnetcore
+# surging的介绍
+```
+ 作者:fanly 校对:fanly
+```
+
+什么是Surging
+
+ surging 是微服务引擎,提供了轻量级,高性能,模块化的RPC请求管道,服务引擎支持http、TCP、WS、Mqtt、UDP、DNS协议,采用了Zookeeper、Consul作为注册中心,集成了哈希,随机,轮询,压力最小优先作为负载均衡的算法,内置了服务治理用来保证可靠性RPC通信
+
+使用surging你可以:
+
+ * 构建Web应用程序,微服务和api网关
+ * 微服务可以部署在docker。可以使用k8s、rancher服务编排弹性扩容
+ * 提供了多协议支持
+ * 支持负载平衡分流压力
+ * 基于.NET Core的跨平台可以在Windows,macOS和Linux上运行;也可以移植到其他操作系统。
+ * 简化的服务调用,通过服务规则的指定,就可以做到服务之间的远程调用,无需其它方式的侵入
+ * 服务自动注册与发现,不需要配置服务提供方地址,注册中心基于ServiceId 或者RoutePath查询服务提供者的地址和元数据,并且能够平滑添加或删除服务提供者。
+ * 软负载均衡及容错机制,通过surging内部负载算法和容错规则的设定,从而达到内部调用的负载和容错
+ * 分布式缓存中间件:通过哈希一致性算法来实现负载,并且有健康检查能够平滑的把不健康的服务从列表中删除
+ * 事件总线:通过对于事件总线的适配可以实现发布订阅交互模式
+ * 容器化持续集成与持续交付 :通过构建一体化Devops平台,实现项目的自动化构建、部署、测试和发布,从而提高生产环境的可靠性、稳定性、弹性和安全性。
+ * 业务模块化驱动引擎,通过加载指定业务模块,能够更加灵活、高效的部署不同版本的业务功能模块
+
+基于surging微服务的开发人员提供以下好处:
+
+ * 统一构建微服务。
+ * 内置依赖注入,您可以自由组合依赖组件。
+ * 内置服务注册中心。
+ * 内置网关可以统一外部访问和管理。
+ * 轻量级,高性能,模块化的RPC请求管道。
+ * 能够在您自己的进程中托管IIS或自托管。
+ * 可以在.NET Core上运行,能够在Windows,macOS和Linux上构建和运行
+ * 简化繁琐的维护。
+ * 基于github平台的开源。
+ * 支持负载平衡分流压力。
+ * 支持多协议服务主机。
+ * 内置服务化治理。
+ * 支持引用、Nuget Install Package、扫描三种方式来加载组件和业务模块
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 000000000..fff2a2778
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,62 @@
+# 关于开发者文档
+
+## 文档简介
+
+## 目录
+- [概述](quick-start/index.md)
+- - [surging 简介]()
+- - [版本更新]()
+- [教程]()
+- - [服务主机如何构建]()
+- - - [依赖注入服务]()
+- - - [配置日志组件]()
+- - - [如何设置成服务提供者]()
+- - - [启动配置]()
+- - - [配置文件构建]()
+- - [协议主机构建]()
+- - - [构建TCP协议服务主机]()
+- - - [构建MQTT协议服务主机]()
+- - - [构建WS协议服务主机]()
+- - - [构建UDP协议服务主机]()
+- - - [构建Http协议服务主机]()
+- - - [构建Dns协议服务主机]()
+- - [如何构建微服务]()
+- - - [微服务规则]()
+- - - [配置routepath]()
+- - - [配置ServiceMetadata]()
+- - - [服务拦截器配置]()
+- - - [配置依赖注入]()
+- - - [如何配置和读取配置项]()
+- - [服务注册发现和服务治理]()
+- - - [consul的注册与发现]()
+- - - [zookeeper的注册与发现]()
+- - - [服务路由的负载均衡]()
+- - - [容错策略]()
+- - - [服务熔断]()
+- - [引擎核心组件]()
+- - - [配置使用Swagger组件]()
+- - - [配置ProtoBuffer、MessagePack或Json.net组件编解码消息]()
+- - - [配置Log4net日志组件]()
+- - - [配置NLog日志组件]()
+- - - [配置Stage关卡组件]()
+- - - [配置扩展SystemModule组件]()
+- - - [配置扩展BusinessModule组件]()
+- - - [配置扩展EnginePartModule组件]()
+- - - [配置扩展KestrelHttpModule组件]()
+- - [中间件]()
+- - - [缓存中间件]()
+- - - [消息中间件]()
+- - [网关]()
+- - - [配置gatewaySettings.json文件]()
+- - - [jwt鉴权]()
+- - - [基于Stage生成的第三方接口网关]()
+- [示例]()
+- - [缓存中间件使用]()
+- - [消息中间件使用]()
+- - [服务之间本地和远程调用]()
+- [部署]()
+- - [引擎部署到window环境中]()
+- - [引擎部署到linux环境容器中]()
+- - [引擎构建镜像push到镜像库]()
+- - [扫描业务模块组件和中间件装载到引擎中]()
+- - [基于rancher 服务编排 ]()
diff --git a/docs/quick-start/index.md b/docs/quick-start/index.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/docs/toc.yml b/docs/toc.yml
new file mode 100644
index 000000000..fb70c2c4d
--- /dev/null
+++ b/docs/toc.yml
@@ -0,0 +1,5 @@
+- name: 开发者文档
+ href: index.md
+- name: 快速开始
+ href: quick-start/index.md
+ topicHref: quick-start/
\ No newline at end of file
diff --git a/index.md b/index.md
new file mode 100644
index 000000000..da1316874
--- /dev/null
+++ b/index.md
@@ -0,0 +1,15 @@
+---
+layout: HubPage
+ms.topic: hub-page
+hide_bc: true
+title:
+description:
+ms.date: "2019.6.29"
+---
+
+# Surging
+
+## 简介
+
+## 社区愿景
+
diff --git a/samples/.gitignore b/samples/.gitignore
deleted file mode 100644
index befad6a88..000000000
--- a/samples/.gitignore
+++ /dev/null
@@ -1,17 +0,0 @@
-/Centa.Agency.HostService/bin
-/Centa.Agency.HostService/obj
-/Centa.Agency.Application.Service/bin
-/Centa.Agency.Application.Service/obj
-/DDD.Core/bin
-/DDD.Core/obj
-/Centa.Agency.Web/bin
-bin
-obj
-/Centa.HostService.SysLog/obj
-/Centa.HostService.SysLog/bin
-/Centa.Agency.Application.Interface/obj
-/Centa.Agency.Domain/obj
-/Centa.Agency.Domain/bin
-/Centa.Agency.Query/bin
-/Centa.Agency.Query/obj
-/Centa.Agency.Web/obj
diff --git a/samples/AuthServer/Application.Interface.Auth/Application.Interface.Auth.csproj b/samples/AuthServer/Application.Interface.Auth/Application.Interface.Auth.csproj
deleted file mode 100644
index 8c27115ea..000000000
--- a/samples/AuthServer/Application.Interface.Auth/Application.Interface.Auth.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
- ..\HostService\bin\Debug
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/AuthServer/Application.Interface.Auth/Dto/LoginReq.cs b/samples/AuthServer/Application.Interface.Auth/Dto/LoginReq.cs
deleted file mode 100644
index acbad5813..000000000
--- a/samples/AuthServer/Application.Interface.Auth/Dto/LoginReq.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using DTO.Core;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Application.Service.Auth.Dto
-{
- public class LoginReq : BaseDto
- {
- public string UserName { get; set; }
- public string Pwd { get; set; }
- public Guid CorporationKeyId { get; set; }
- }
-}
diff --git a/samples/AuthServer/Application.Interface.Auth/Event/CorporationActivated.cs b/samples/AuthServer/Application.Interface.Auth/Event/CorporationActivated.cs
deleted file mode 100644
index 11f421dad..000000000
--- a/samples/AuthServer/Application.Interface.Auth/Event/CorporationActivated.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Surging.Core.CPlatform.EventBus.Events;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Application.Interface.Auth.EVENT
-{
- // ///
- // /// 新注册公司被激活的事件
- // ///
- //public class CorporationActivatedEvent: IntegrationEvent
- // {
-
- // }
-}
diff --git a/samples/AuthServer/Application.Interface.Auth/Event/IAuthEventHandler.cs b/samples/AuthServer/Application.Interface.Auth/Event/IAuthEventHandler.cs
deleted file mode 100644
index 93ae5b0b7..000000000
--- a/samples/AuthServer/Application.Interface.Auth/Event/IAuthEventHandler.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Application.Interface.Org.EVENT;
-using Surging.Core.CPlatform.EventBus.Events;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Application.Interface.Auth.EVENT
-{
- ///
- /// 事件处理器
- ///
- public interface IAuthEventHandler : IIntegrationEventHandler
- {
- }
-}
diff --git a/samples/AuthServer/Application.Interface.Auth/IAuthAppService.cs b/samples/AuthServer/Application.Interface.Auth/IAuthAppService.cs
deleted file mode 100644
index 3b899c1ea..000000000
--- a/samples/AuthServer/Application.Interface.Auth/IAuthAppService.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using Application.Service.Auth.Dto;
-using DTO.Core;
-using Surging.Core.CPlatform.Ioc;
-using Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Attributes;
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-namespace Application.Interface.Auth
-{
- [ServiceBundle("api/{Service}")]
- public interface IAuthAppService : IServiceKey
- {
-
- ///
- /// 登录系统
- ///
- ///
- [Service(Date = "2018-1-30", Director = "刘旭东", Name = "登录系统")]
- Task SignIn( LoginReq req);
-
- ///
- /// 退出系统
- ///
- ///
- [Service(Date = "2018-1-30", Director = "刘旭东", Name = "退出系统")]
- Task SignUp(CommonCMDReq req);
-
- [Service(Date = "2018-1-30", Director = "刘旭东", Name = "查询系统模块下的所有权限")]
- Task FindDomainPermissions(CommonCMDReq req);
- }
-}
diff --git a/samples/AuthServer/Application.Service.Auth/Application.Service.Auth.csproj b/samples/AuthServer/Application.Service.Auth/Application.Service.Auth.csproj
deleted file mode 100644
index 0e9898f87..000000000
--- a/samples/AuthServer/Application.Service.Auth/Application.Service.Auth.csproj
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
- ..\HostService\bin\Debug
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/AuthServer/Application.Service.Auth/EventHandling/AuthEventHandler.cs b/samples/AuthServer/Application.Service.Auth/EventHandling/AuthEventHandler.cs
deleted file mode 100644
index ab81150ff..000000000
--- a/samples/AuthServer/Application.Service.Auth/EventHandling/AuthEventHandler.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using App.Core.Security;
-using Application.Interface.Auth.EVENT;
-using Application.Interface.Org.EVENT;
-using Domain.Auth.Aggregate;
-using Repository.Auth;
-using Surging.Core.ProxyGenerator;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Application.Service.Auth.EventHandling
-{
- //[QueueConsumerAttribute]
- public class AuthEventHandler : IAuthEventHandler
- {
- private readonly UserRepository _userRepository;
- private readonly SubDomainRepository _subDomainRepository;
- private readonly UserQueryRepository _queryUserRepository;
- private readonly SubDomainQueryRepository _querySubDomainRepository;
- // private ICacheProvider _cacheProvider;
- public AuthEventHandler(UserRepository userRepository, UserQueryRepository queryUserRepository,
- SubDomainRepository subDomainRepository, SubDomainQueryRepository querySubDomainRepository)
- {
- _userRepository = userRepository;
- _subDomainRepository = subDomainRepository;
- _queryUserRepository = queryUserRepository;
- _querySubDomainRepository = querySubDomainRepository;
- }
-
-
- public Task Handle(CorporationActivatedEvent @event)
- {
- //需要为企业管理做初始化,并生成管理员账号
- return Task.Run(() =>
- {
- var encryptionService = new EncryptionService();
- _userRepository.Add(new User
- {
- CorporationKeyId = @event.CorpId,
- IsDelete = false,
- EmployeeKeyID = Guid.Parse(@event.EmpId),
- KeyId = Guid.NewGuid(),
- Name = "超级管理员",
- No = "SuperMan",
- Version = 1,
- Pwd = encryptionService.EncryptText("123456")
- });
-
- _userRepository.Commit();
- });
-
- }
- }
-}
diff --git a/samples/AuthServer/Application.Service.Auth/Query/AuthAppService.cs b/samples/AuthServer/Application.Service.Auth/Query/AuthAppService.cs
deleted file mode 100644
index d6db7d3de..000000000
--- a/samples/AuthServer/Application.Service.Auth/Query/AuthAppService.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using DTO.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Application.Service.Auth
-{
- public partial class AuthAppService
- {
- public Task FindDomainPermissions(CommonCMDReq req)
- {
- BaseListResponseDto rsp = new BaseListResponseDto();
- var rows= _querySubDomainRepository.Get(a => !a.IsDelete,b=>b.SubDomainPermissions).ToList();
- rsp.Result = rows.Select(a => new {
- keyId = a.KeyId,
- domainNmae = a.Name,
- action = a.SubDomainPermissions.Where(b=>b.PermissionType== Domain.Auth.Entity.PermissionCategory.Action)?.GroupBy(b => b.GroupName, c => new {
- name=c.Name,
- no=c.No
- }).ToDictionary(b=>b.Key,c=>c),
- page = a.SubDomainPermissions.Where(b => b.PermissionType == Domain.Auth.Entity.PermissionCategory.Page)?.Select(c => new {
- name = c.Name,
- no = c.No
- }).ToList()
- }).ToList();
- return Task.FromResult(rsp);
- }
-
- }
-}
diff --git a/samples/AuthServer/Application.Service.Auth/UseCases/AuthAppService.cs b/samples/AuthServer/Application.Service.Auth/UseCases/AuthAppService.cs
deleted file mode 100644
index f3d351d92..000000000
--- a/samples/AuthServer/Application.Service.Auth/UseCases/AuthAppService.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using App.Core.Security;
-using Application.Interface.Auth;
-using Application.Service.Auth.Dto;
-using Domain.Auth.Aggregate;
-using DTO.Core;
-using Repository.Auth;
-using Surging.Core.Caching;
-using Surging.Core.CPlatform.Ioc;
-using Surging.Core.ProxyGenerator;
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-namespace Application.Service.Auth
-{
- [ModuleName("Auth")]
- public partial class AuthAppService : ProxyServiceBase, IAuthAppService
- {
- private readonly UserRepository _userRepository;
- private readonly SubDomainRepository _subDomainRepository;
- private readonly UserQueryRepository _queryUserRepository;
- private readonly SubDomainQueryRepository _querySubDomainRepository;
- // private ICacheProvider _cacheProvider;
- public AuthAppService(UserRepository userRepository, UserQueryRepository queryUserRepository,
- SubDomainRepository subDomainRepository, SubDomainQueryRepository querySubDomainRepository)
- {
- _userRepository = userRepository;
- _subDomainRepository = subDomainRepository;
- _queryUserRepository = queryUserRepository;
- _querySubDomainRepository = querySubDomainRepository;
- }
-
- public Task SignIn(LoginReq req)
- {
- User user=null;
- try {
- //缓存增加当前用户相关信息
- //_cacheProvider= CacheContainer.GetInstances("Redis");
- //_cacheProvider.Add("UserKeyId=22", "{ UserKeyId=22,TenantId=3}");
- var encryptionService = new EncryptionService();
- var pwde = encryptionService.EncryptText(req.Pwd);
- user = _queryUserRepository.GetSingle(a => a.CorporationKeyId == req.CorporationKeyId && !a.IsDelete && a.Pwd == pwde && a.No == req.UserName);
- }
- catch (Exception ex)
- {
- string ss = ex.Message;
- }
- if (user != null)
- {
- return Task.FromResult(new TokenDto { CorporationKeyId = user.CorporationKeyId, Token = user.EmployeeKeyID.ToString() });
-
- }
- else
- {
- return Task.FromResult(null);
- }
- }
-
- public Task SignUp(CommonCMDReq req)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/samples/AuthServer/Domain/Aggregate/SubDomain.cs b/samples/AuthServer/Domain/Aggregate/SubDomain.cs
deleted file mode 100644
index ba5963c54..000000000
--- a/samples/AuthServer/Domain/Aggregate/SubDomain.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using DDD.Core;
-using Domain.Auth.Entity;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Text;
-
-namespace Domain.Auth.Aggregate
-{
- ///
- /// 服务模块(子领域)
- ///
- [Table("Auth_SubDomains")]
- public class SubDomain : IAggregate
- {
-
- ///
- /// 模块下的权限
- ///
- public virtual List SubDomainPermissions { get; set; }
-
- }
-}
diff --git a/samples/AuthServer/Domain/Aggregate/User.cs b/samples/AuthServer/Domain/Aggregate/User.cs
deleted file mode 100644
index 2135d1a39..000000000
--- a/samples/AuthServer/Domain/Aggregate/User.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using DDD.Core;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Text;
-
-namespace Domain.Auth.Aggregate
-{
- ///
- /// 平台用户(账号)
- ///
- [Table("Auth_Users")]
- public class User : IAggregate
- {
-
- ///
- /// 密码
- ///
- public string Pwd { get; set; }
-
-
- ///
- /// 归属员工
- ///
- public Guid EmployeeKeyID { get; set; }
-
-
- //public virtual List Departments { get; set; }
-
- }
-}
diff --git a/samples/AuthServer/Domain/Domain.Auth.csproj b/samples/AuthServer/Domain/Domain.Auth.csproj
deleted file mode 100644
index 557735dc9..000000000
--- a/samples/AuthServer/Domain/Domain.Auth.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
- ..\HostService\bin\Debug
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/AuthServer/Domain/Entity/SubDomainPermission.cs b/samples/AuthServer/Domain/Entity/SubDomainPermission.cs
deleted file mode 100644
index b34a3e9dc..000000000
--- a/samples/AuthServer/Domain/Entity/SubDomainPermission.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using DDD.Core;
-using Domain.Auth.Aggregate;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Text;
-
-namespace Domain.Auth.Entity
-{
- ///
- /// 模块下的权限
- ///
- [Table("Auth_SubDomain_Permissions")]
- public class SubDomainPermission : BaseEntity
- {
- public string GroupName { get; set; }
- public string GroupNo { get; set; }
-
- public PermissionCategory PermissionType { get; set; }
-
- public Guid SubDomainKeyId { get; set; }
-
- [ForeignKey("SubDomainKeyId")]
- public SubDomain SubDomain { get; set; }
- }
-
- public enum PermissionCategory
- {
- ///
- /// 页面
- ///
- Page=1,
-
- ///
- /// 动作
- ///
- Action=2
- }
-}
diff --git a/samples/AuthServer/Domain/Repository/UserRepository.cs b/samples/AuthServer/Domain/Repository/UserRepository.cs
deleted file mode 100644
index 00c3f69c7..000000000
--- a/samples/AuthServer/Domain/Repository/UserRepository.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Domain.Auth.Aggregate;
-using Microsoft.EntityFrameworkCore;
-using Repository.EF.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace Domain.Auth.Repository
-{
-
-}
diff --git a/samples/AuthServer/Domain/ValueObject/InquiryParameter.cs b/samples/AuthServer/Domain/ValueObject/InquiryParameter.cs
deleted file mode 100644
index 4dcf8b670..000000000
--- a/samples/AuthServer/Domain/ValueObject/InquiryParameter.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using DDD.Core;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Text;
-
-namespace Domain.ValueObject.Inquiry
-{
-
- public class InquiryParameter: BaseValueObject
- {
- // [Column("InquiryKeyId")]
- public Guid InquiryKeyId { get; set; }
- // [ForeignKey("InquiryKeyId")]
- // public CusInquiry OwnCusInquiry { get; set; }
-
- public Guid SysParameterItemKeyId { get; set; }
- public int ParameterType { get; set; }
- public int Seq { get; set; }
- /*
- [InverseProperty("Author")]
- public List AuthoredPosts { get; set; }
-
- [InverseProperty("Contributor")]
- public List ContributedToPosts { get; set; }
- */
-
- }
-}
diff --git a/samples/AuthServer/HostService/Configs/log4net.config b/samples/AuthServer/HostService/Configs/log4net.config
deleted file mode 100644
index 42fd16880..000000000
--- a/samples/AuthServer/HostService/Configs/log4net.config
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/AuthServer/HostService/HostService.csproj b/samples/AuthServer/HostService/HostService.csproj
deleted file mode 100644
index 6fc04dddc..000000000
--- a/samples/AuthServer/HostService/HostService.csproj
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
- Exe
- netcoreapp2.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
diff --git a/samples/AuthServer/HostService/Program.cs b/samples/AuthServer/HostService/Program.cs
deleted file mode 100644
index fd254ab5b..000000000
--- a/samples/AuthServer/HostService/Program.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using Autofac;
-using Surging.Core.Codec.MessagePack;
-using Surging.Core.Consul;
-using Surging.Core.Consul.Configurations;
-using Surging.Core.CPlatform;
-using Surging.Core.CPlatform.Utilities;
-using Surging.Core.DotNetty;
-using Surging.Core.EventBusRabbitMQ;
-using Surging.Core.ServiceHosting;
-using Surging.Core.ServiceHosting.Internal.Implementation;
-using System;
-using System.Text;
-using Surging.Core.Log4net;
-using Surging.Core.ProxyGenerator;
-
-namespace Centa.HostService.Auth
-{
- public class Program
- {
- static void Main(string[] args)
- {
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
- var host = new ServiceHostBuilder()
- .RegisterServices(builder =>
- {
- // builder.RegisterAssemblyModules();
- //这里写自己的注册
- })
- .RegisterServices(builder =>
- {
- builder.AddMicroService(option =>
- {
- option.AddServiceRuntime();
- option.AddRelateService();
- option.UseConsulManager(new ConfigInfo("127.0.0.1:8500"));
- option.UseDotNettyTransport();
- option.UseRabbitMQTransport();
- option.AddRabbitMQAdapt();
- //option.UseMessagePackCodec();
- option.UseJsonCodec();
- builder.Register(p => new CPlatformContainer(ServiceLocator.Current));
- });
- })
- .SubscribeAt()
- .UseLog4net("Configs/log4net.config")
- .UseServer(options =>
- {
- options.Ip = "127.0.0.1";
- options.Port = 10241;
- options.Token = "True";
- options.ExecutionTimeoutInMilliseconds = 30000;
- options.MaxConcurrentRequests = 200;
- })
- .UseProxy()
- .UseStartup()
- .Build();
-
- using (host.Run())
- {
- Console.Title = "认证授权";
- Console.WriteLine($"认证授权——服务端启动成功,{DateTime.Now}。");
- Console.ReadLine();
- }
- }
- }
-}
diff --git a/samples/AuthServer/HostService/Startup.cs b/samples/AuthServer/HostService/Startup.cs
deleted file mode 100644
index 84043e018..000000000
--- a/samples/AuthServer/HostService/Startup.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using Autofac;
-using Autofac.Extensions.DependencyInjection;
-using Config.Core.Extensions;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Surging.Core.Caching.Configurations;
-using Surging.Core.CPlatform.Utilities;
-using Surging.Core.EventBusRabbitMQ.Configurations;
-using System;
-
-namespace Centa.HostService.Auth
-{
- public class Startup
- {
- public Startup()
- {
- var config = new ConfigurationBuilder()
- .SetBasePath(AppContext.BaseDirectory);
- ConfigureEventBus(config);
- ConfigureCache(config);
- ConfigureDB(config);
-
- }
-
- public IContainer ConfigureServices(ContainerBuilder builder)
- {
- var services = new ServiceCollection();
- ConfigureLogging(services);
- builder.Populate(services);
- ServiceLocator.Current = builder.Build();
- return ServiceLocator.Current;
- }
-
- public void Configure(IContainer app)
- {
- app.Resolve().AddConsole((c, l) => (int)l >= 3);
- }
-
- #region 私有方法
- ///
- /// 配置日志服务
- ///
- ///
- private void ConfigureLogging(IServiceCollection services)
- {
- services.AddLogging();
- }
-
- private static void ConfigureEventBus(IConfigurationBuilder build)
- {
- build
- .AddEventBusFile("eventBusSettings.json", optional: false);
- }
-
- ///
- /// 配置缓存服务
- ///
- private void ConfigureCache(IConfigurationBuilder build)
- {
- build.AddCacheFile("cacheSettings.json", optional: false);
- }
-
- private void ConfigureDB(IConfigurationBuilder build)
- {
- build.AddDBFile("dbSettings.json", optional: false);
- }
- #endregion
-
- }
-}
diff --git a/samples/AuthServer/HostService/cacheSettings.json b/samples/AuthServer/HostService/cacheSettings.json
deleted file mode 100644
index ab9c7e43d..000000000
--- a/samples/AuthServer/HostService/cacheSettings.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "CachingSettings": [
- {
- "Id": "ddlCache",
- "Class": "Surging.Core.Caching.RedisCache.RedisContext,Surging.Core.Caching",
- "Properties": [
- {
- "Name": "appRuleFile",
- "Ref": "rule"
- },
- {
- "Name": "dataContextPool",
- "Ref": "ddls_sample",
- "Maps": [
- {
- "Name": "Redis",
- "Properties": [
- {
- "value": "127.0.0.1:6379::1"
- }
- ]
- },
- {
- "Name": "MemoryCache"
- }
- ]
- },
- {
- "Name": "defaultExpireTime",
- "value": "120"
- },
- {
- "Name": "connectTimeout",
- "Value": "120"
- },
- {
- "Name": "minSize",
- "Value": "1"
- },
- {
- "Name": "maxSize",
- "Value": "10"
- }
- ]
- }
- ]
-}
diff --git a/samples/AuthServer/HostService/dbSettings.json b/samples/AuthServer/HostService/dbSettings.json
deleted file mode 100644
index 9903dfd68..000000000
--- a/samples/AuthServer/HostService/dbSettings.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "ConnectionString": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=Web_A2;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
- "ModelAssemblyName": "Domain.Auth"
-}
-
diff --git a/samples/AuthServer/HostService/eventBusSettings.json b/samples/AuthServer/HostService/eventBusSettings.json
deleted file mode 100644
index d5d4487b7..000000000
--- a/samples/AuthServer/HostService/eventBusSettings.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "EventBusConnection": "localhost",
- "EventBusUserName": "guest",
- "EventBusPassword": "guest"
-}
-
diff --git a/samples/AuthServer/Repository.Auth/AuthRepository.cs b/samples/AuthServer/Repository.Auth/AuthRepository.cs
deleted file mode 100644
index 25ce7ba6c..000000000
--- a/samples/AuthServer/Repository.Auth/AuthRepository.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using DDD.Core;
-using Domain.Auth.Aggregate;
-using Microsoft.EntityFrameworkCore;
-using Repository.EF.Core;
-using Surging.Core.CPlatform.Ioc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Text;
-
-namespace Repository.Auth
-{
-
-
-
- public class UserRepository : BaseImpRepository
- {
- public override User FindBy(Guid key)
- {
- return _set //.Include(a => a.Departments).ThenInclude(a => a.Employees)
- .SingleOrDefault(a => a.KeyId == key);
- }
- }
-
- public class SubDomainRepository : BaseImpRepository
- {
- public override SubDomain FindBy(Guid key)
- {
- return _set //.Include(a => a.Departments).ThenInclude(a => a.Employees)
- .SingleOrDefault(a => a.KeyId == key);
- }
- }
-
- public class UserQueryRepository : BaseImpQueryOnlyRepository
- {
- }
-
- public class SubDomainQueryRepository : BaseImpQueryOnlyRepository
- {
-
- public override IQueryable Get(Expression> where = null)
- {
- return _set.Include(a => a.SubDomainPermissions).Where(where);
- }
- }
-
-}
diff --git a/samples/AuthServer/Repository.Auth/Repository.Auth.csproj b/samples/AuthServer/Repository.Auth/Repository.Auth.csproj
deleted file mode 100644
index 9fb3bffee..000000000
--- a/samples/AuthServer/Repository.Auth/Repository.Auth.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
- ..\HostService\bin\Debug
-
-
-
-
-
-
-
-
diff --git a/samples/Common/App.Core/App.Core.csproj b/samples/Common/App.Core/App.Core.csproj
deleted file mode 100644
index df1909e24..000000000
--- a/samples/Common/App.Core/App.Core.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/Common/App.Core/BaseAppService.cs b/samples/Common/App.Core/BaseAppService.cs
deleted file mode 100644
index a7b6e682c..000000000
--- a/samples/Common/App.Core/BaseAppService.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Repository.EF.Core;
-using Surging.Core.ProxyGenerator;
-using System;
-
-namespace App.Core
-{
- public class BaseAppService : ProxyServiceBase
- {
- // protected BaseImpRepository _repository;
- //protected QueryOrgRepository _queryOnlyRepository;
- public BaseAppService()//(BaseImpRepository repository)//, QueryOrgRepository queryOnlyRepository)
- {
- // _repository = repository;
- //_queryOnlyRepository = queryOnlyRepository;
- }
- }
-}
diff --git a/samples/Common/App.Core/Security/EncryptionService.cs b/samples/Common/App.Core/Security/EncryptionService.cs
deleted file mode 100644
index 36159e03e..000000000
--- a/samples/Common/App.Core/Security/EncryptionService.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-using System;
-using System.IO;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace App.Core.Security
-{
- ///
- /// Encryption service
- ///
- public class EncryptionService : IEncryptionService
- {
- #region Fields
-
- private readonly dynamic _securitySettings ;
- private readonly string EncryptionKey = "loveC#loveC#loveC#";
- #endregion
-
- #region Ctor
- public EncryptionService()
- {
- //_securitySettings.EncryptionKey = "loveC#";
- }
-
-
- #endregion
-
- #region Utilities
-
- private byte[] EncryptTextToMemory(string data, byte[] key, byte[] iv)
- {
- using (var ms = new MemoryStream()) {
- using (var cs = new CryptoStream(ms, new TripleDESCryptoServiceProvider().CreateEncryptor(key, iv), CryptoStreamMode.Write)) {
- var toEncrypt = Encoding.Unicode.GetBytes(data);
- cs.Write(toEncrypt, 0, toEncrypt.Length);
- cs.FlushFinalBlock();
- }
-
- return ms.ToArray();
- }
- }
-
- private string DecryptTextFromMemory(byte[] data, byte[] key, byte[] iv)
- {
- using (var ms = new MemoryStream(data)) {
- using (var cs = new CryptoStream(ms, new TripleDESCryptoServiceProvider().CreateDecryptor(key, iv), CryptoStreamMode.Read))
- {
- using (var sr = new StreamReader(cs, Encoding.Unicode))
- {
- return sr.ReadToEnd();
- }
- }
- }
- }
-
- #endregion
-
- #region Methods
-
- ///
- /// Create salt key
- ///
- /// Key size
- /// Salt key
- public virtual string CreateSaltKey(int size)
- {
- //generate a cryptographic random number
- using (var provider = new RNGCryptoServiceProvider())
- {
- var buff = new byte[size];
- provider.GetBytes(buff);
-
- // Return a Base64 string representation of the random number
- return Convert.ToBase64String(buff);
- }
- }
-
- ///
- /// Create a password hash
- ///
- /// Password
- /// Salk key
- /// Password format (hash algorithm)
- /// Password hash
- public virtual string CreatePasswordHash(string password, string saltkey, string passwordFormat)
- {
- return CreateHash(Encoding.UTF8.GetBytes(string.Concat(password, saltkey)), passwordFormat);
- }
-
- ///
- /// Create a data hash
- ///
- /// The data for calculating the hash
- /// Hash algorithm
- /// Data hash
- public virtual string CreateHash(byte[] data, string hashAlgorithm)
- {
- if (string.IsNullOrEmpty(hashAlgorithm))
- throw new ArgumentNullException(nameof(hashAlgorithm));
-
- var algorithm = HashAlgorithm.Create(hashAlgorithm);
- if (algorithm == null)
- throw new ArgumentException("Unrecognized hash name");
-
- var hashByteArray = algorithm.ComputeHash(data);
- return BitConverter.ToString(hashByteArray).Replace("-", "");
- }
-
- ///
- /// Encrypt text
- ///
- /// Text to encrypt
- /// Encryption private key
- /// Encrypted text
- public virtual string EncryptText(string plainText, string encryptionPrivateKey = "")
- {
- if (string.IsNullOrEmpty(plainText))
- return plainText;
-
- if (string.IsNullOrEmpty(encryptionPrivateKey))
- encryptionPrivateKey = EncryptionKey;// _securitySettings.EncryptionKey;
-
- using (var provider = new TripleDESCryptoServiceProvider())
- {
- provider.Key = Encoding.ASCII.GetBytes(encryptionPrivateKey.Substring(0, 16));
- provider.IV = Encoding.ASCII.GetBytes(encryptionPrivateKey.Substring(8, 8));
-
- var encryptedBinary = EncryptTextToMemory(plainText, provider.Key, provider.IV);
- return Convert.ToBase64String(encryptedBinary);
- }
- }
-
- ///
- /// Decrypt text
- ///
- /// Text to decrypt
- /// Encryption private key
- /// Decrypted text
- public virtual string DecryptText(string cipherText, string encryptionPrivateKey = "")
- {
- if (string.IsNullOrEmpty(cipherText))
- return cipherText;
-
- if (string.IsNullOrEmpty(encryptionPrivateKey))
- encryptionPrivateKey = EncryptionKey;// _securitySettings.EncryptionKey;
-
- using (var provider = new TripleDESCryptoServiceProvider())
- {
- provider.Key = Encoding.ASCII.GetBytes(encryptionPrivateKey.Substring(0, 16));
- provider.IV = Encoding.ASCII.GetBytes(encryptionPrivateKey.Substring(8, 8));
-
- var buffer = Convert.FromBase64String(cipherText);
- return DecryptTextFromMemory(buffer, provider.Key, provider.IV);
- }
- }
-
- #endregion
- }
-}
diff --git a/samples/Common/App.Core/Security/IEncryptionService.cs b/samples/Common/App.Core/Security/IEncryptionService.cs
deleted file mode 100644
index 57c6af36c..000000000
--- a/samples/Common/App.Core/Security/IEncryptionService.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace App.Core.Security
-{
- ///
- /// Encryption service
- ///
- public interface IEncryptionService
- {
- ///
- /// Create salt key
- ///
- /// Key size
- /// Salt key
- string CreateSaltKey(int size);
-
- ///
- /// Create a password hash
- ///
- /// Password
- /// Salk key
- /// Password format (hash algorithm)
- /// Password hash
- string CreatePasswordHash(string password, string saltkey, string passwordFormat);
-
- ///
- /// Create a data hash
- ///
- /// The data for calculating the hash
- /// Hash algorithm
- /// Data hash
- string CreateHash(byte [] data, string hashAlgorithm);
-
- ///
- /// Encrypt text
- ///
- /// Text to encrypt
- /// Encryption private key
- /// Encrypted text
- string EncryptText(string plainText, string encryptionPrivateKey = "");
-
- ///
- /// Decrypt text
- ///
- /// Text to decrypt
- /// Encryption private key
- /// Decrypted text
- string DecryptText(string cipherText, string encryptionPrivateKey = "");
- }
-}
diff --git a/samples/Common/Config.Core/Config.Core.csproj b/samples/Common/Config.Core/Config.Core.csproj
deleted file mode 100644
index 89c8baf3a..000000000
--- a/samples/Common/Config.Core/Config.Core.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
-
-
-
-
-
- C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration.fileextensions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.FileExtensions.dll
-
-
-
-
diff --git a/samples/Common/Config.Core/DBConfigurationExtensions.cs b/samples/Common/Config.Core/DBConfigurationExtensions.cs
deleted file mode 100644
index 15a651324..000000000
--- a/samples/Common/Config.Core/DBConfigurationExtensions.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.FileProviders;
-using Surging.Core.CPlatform.Configurations.Remote;
-using Surging.Core.CPlatform.Utilities;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace Config.Core.Extensions
-{
- public static class DBConfigurationExtensions
- {
- public static IConfigurationBuilder AddDBFile(this IConfigurationBuilder builder, string path)
- {
- return AddDBFile(builder, provider: null, path: path, optional: false, reloadOnChange: false);
- }
-
- public static IConfigurationBuilder AddDBFile(this IConfigurationBuilder builder, string path, bool optional)
- {
- return AddDBFile(builder, provider: null, path: path, optional: optional, reloadOnChange: false);
- }
-
- public static IConfigurationBuilder AddDBFile(this IConfigurationBuilder builder, string path, bool optional, bool reloadOnChange)
- {
- return AddDBFile(builder, provider: null, path: path, optional: optional, reloadOnChange: reloadOnChange);
- }
-
- public static IConfigurationBuilder AddDBFile(this IConfigurationBuilder builder, IFileProvider provider, string path, bool optional, bool reloadOnChange)
- {
- Check.NotNull(builder, "builder");
- Check.CheckCondition(() => string.IsNullOrEmpty(path), "path");
- if (provider == null && Path.IsPathRooted(path))
- {
- provider = new PhysicalFileProvider(Path.GetDirectoryName(path));
- path = Path.GetFileName(path);
- }
- var source = new DBConfigurationSource
- {
- FileProvider = provider,
- Path = path,
- Optional = optional,
- ReloadOnChange = reloadOnChange
- };
- builder.Add(source);
- DBConfig.Configuration = builder.Build();
- return builder;
- }
- }
- public class DBConfig
- {
-
- public static IConfiguration Configuration { get; set; }
- /* static ConfigHelper()
- {
- configuration = AutofacContainer.Resolve();
- }
-
- public static IConfigurationSection GetSection(string key)
- {
- return configuration.GetSection(key);
- }
-
- public static string GetConfigurationValue(string key)
- {
- return configuration[key];
- }
-
- public static string GetConfigurationValue(string section, string key)
- {
- return GetSection(section)?[key];
- }
-
- public static string GetConnectionString(string key)
- {
- return configuration.GetConnectionString(key);
- }
- */
- }
-
- public class DBConfigurationSource : FileConfigurationSource
- {
- public string ConfigurationKeyPrefix { get; set; }
-
- public override IConfigurationProvider Build(IConfigurationBuilder builder)
- {
- FileProvider = FileProvider ?? builder.GetFileProvider();
- return new DBConfigurationProvider(this);
- }
- }
- public class DBConfigurationProvider : FileConfigurationProvider
- {
- public DBConfigurationProvider(DBConfigurationSource source) : base(source) { }
-
- public override void Load(Stream stream)
- {
- var parser = new JsonConfigurationParser();
- this.Data = parser.Parse(stream, null);
- }
- }
-}
diff --git a/samples/Common/DDD.Core/BaseEntity.cs b/samples/Common/DDD.Core/BaseEntity.cs
deleted file mode 100644
index 9093f51b4..000000000
--- a/samples/Common/DDD.Core/BaseEntity.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Text;
-
-namespace DDD.Core
-{
- public abstract class BaseEntity : IDBModel
- {
- [Key]
- public Guid KeyId { get; set; }
- public virtual Guid CorporationKeyId { get; set; }
- public virtual DateTime CreateTime { get; set; }
- public virtual Guid CreateUserKeyId { get; set; }
- public virtual DateTime UpdateTime { get; set; }
- public virtual Guid UpdateUserKeyId { get; set; }
- public virtual bool IsDelete { get; set; }
- public virtual int Version { get; set; }
-
- //2-12增加名字、编号
- public string Name { get; set; }
-
- public string No { get; set; }
-
- public virtual void SetEditer(Guid? editer)
- {
- if(this.KeyId==Guid.Empty)
- {
- this.CreateTime = DateTime.Now;
- this.CreateUserKeyId = Guid.Empty;
- this.UpdateUserKeyId = Guid.Empty;
- this.UpdateTime = DateTime.Now;
- }
- else
- {
- if (editer.HasValue)
- {
- this.UpdateUserKeyId = editer.Value;
- this.UpdateTime = DateTime.Now;
- }
- }
- }
- }
-}
diff --git a/samples/Common/DDD.Core/BaseValueObject.cs b/samples/Common/DDD.Core/BaseValueObject.cs
deleted file mode 100644
index 91399b62b..000000000
--- a/samples/Common/DDD.Core/BaseValueObject.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Text;
-
-namespace DDD.Core
-{
- public abstract class BaseValueObject : IDBModel
- {
- [Key]
- public Guid KeyId { get; set; }
- public virtual Guid CorporationKeyId { get; set; }
- public virtual DateTime CreateTime { get; set; }
- public virtual Guid CreateUserKeyId { get; set; }
- public virtual DateTime UpdateTime { get; set; }
- public virtual Guid UpdateUserKeyId { get; set; }
- public virtual bool IsDelete { get; set; }
- public virtual int Version { get; set; }
-
- public string Name { get; set; }
-
- public string No { get; set; }
- }
-}
diff --git a/samples/Common/DDD.Core/DDD.Core.Extensions/GenericExtension.cs b/samples/Common/DDD.Core/DDD.Core.Extensions/GenericExtension.cs
deleted file mode 100644
index 35919f27c..000000000
--- a/samples/Common/DDD.Core/DDD.Core.Extensions/GenericExtension.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Reflection;
-
-namespace DDD.Core.Extensions
-{
- ///
- /// 泛型扩展
- ///
- public static class GenericExtension
- {
- public static bool Equal(this T x, T y)
- {
- return ((IComparable)(x)).CompareTo(y) == 0;
- }
-
- #region ToDictionary
-
- public static Dictionary ToDictionary(this T t, Dictionary dic = null) where T : class
- {
- if (dic == null)
- dic = new Dictionary();
- var properties = t.GetType().GetProperties();
- foreach (var property in properties)
- {
- var value = property.GetValue(t, null);
- dic.Add(property.Name, value?.ToString() ?? "");
- }
- return dic;
- }
-
- public static Dictionary ToDictionary(this TInterface t, Dictionary dic = null) where T : class, TInterface
- {
- if (dic == null)
- dic = new Dictionary();
- var properties = typeof(T).GetProperties();
- foreach (var property in properties)
- {
- var value = property.GetValue(t, null);
- if (value == null) continue;
- dic.Add(property.Name, value?.ToString() ?? "");
- }
- return dic;
- }
-
- #endregion
-
- ///
- /// 将字符串转换为指定的类型,如果转换不成功,返回默认值。
- ///
- /// 结构体类型或枚举类型
- /// 需要转换的字符串
- /// 返回指定的类型。
- public static T ParseTo(this string str) where T : struct
- {
- return str.ParseTo(default(T));
- }
-
- ///
- /// 将字符串转换为指定的类型,如果转换不成功,返回默认值。
- ///
- /// 结构体类型或枚举类型
- /// 需要转换的字符串
- /// 如果转换失败,需要使用的默认值
- /// 返回指定的类型。
- public static T ParseTo(this string str, T defaultValue) where T : struct
- {
- var t = str.ParseToNullable();
- if (t.HasValue)
- {
- return t.Value;
- }
- return defaultValue;
- }
-
- ///
- /// 将字符串转换为指定的类型,如果转换不成功,返回null
- ///
- /// 结构体类型或枚举类型
- /// 需要转换的字符串
- /// 返回指定的类型
- public static T? ParseToNullable(this string str) where T : struct
- {
- if (string.IsNullOrEmpty(str))
- {
- return null;
- }
- var typeFromHandle = typeof(T);
- if (typeFromHandle.IsEnum)
- {
- return str.ToEnum();
- }
- return (T?)str.ParseTo(typeFromHandle.FullName);
- }
-
- public static DataTable ToDataTable(this IEnumerable source)
- {
- DataTable dtReturn = new DataTable();
-
- // column names
- PropertyInfo[] oProps = null;
-
- if (source == null) return dtReturn;
-
- foreach (var rec in source)
- {
- // Use reflection to get property names, to create table, Only first time, others will follow
- if (oProps == null)
- {
- oProps = rec.GetType().GetProperties();
- foreach (var pi in oProps)
- {
- var colType = pi.PropertyType;
-
- if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))
- {
- colType = colType.GetGenericArguments()[0];
- }
-
- dtReturn.Columns.Add(new DataColumn(pi.Name, colType));
- }
- }
-
- var dr = dtReturn.NewRow();
-
- foreach (var pi in oProps)
- {
- dr[pi.Name] = pi.GetValue(rec, null) == null
- ? DBNull.Value
- : pi.GetValue
- (rec, null);
- }
-
- dtReturn.Rows.Add(dr);
- }
- return dtReturn;
- }
- }
-}
diff --git a/samples/Common/DDD.Core/DDD.Core.Extensions/ObjectExtension.cs b/samples/Common/DDD.Core/DDD.Core.Extensions/ObjectExtension.cs
deleted file mode 100644
index 306776e06..000000000
--- a/samples/Common/DDD.Core/DDD.Core.Extensions/ObjectExtension.cs
+++ /dev/null
@@ -1,1181 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Web;
-using System.Xml;
-using System.Xml.Linq;
-
-namespace DDD.Core.Extensions
-{
- public static class ObjectExtension
- {
- ///
- /// 将集合转换为数据集。
- ///
- /// 转换的元素类型。
- /// 集合。
- /// 是否生成泛型数据集。
- /// 数据集。
- public static DataSet ToDataSet(this IEnumerable list, bool generic = true)
- {
- return ListToDataSet(list, generic);
- }
-
- ///
- /// 将集合转换为数据集。
- ///
- /// 集合。
- /// 是否生成泛型数据集。
- /// 数据集。
- public static DataSet ToDataSet(this IEnumerable list, bool generic = true)
- {
- return ListToDataSet(list, generic);
- }
-
- ///
- /// 将集合转换为数据集。
- ///
- /// 转换的元素类型。
- /// 集合。
- /// 是否生成泛型数据集。
- /// 数据集。
- public static DataSet ToDataSet(this IEnumerable list, bool generic = true)
- {
- return ListToDataSet(list, typeof(T), generic);
- }
-
- ///
- /// 将实例转换为集合数据集。
- ///
- /// 实例类型。
- /// 实例。
- /// 是否生成泛型数据集。
- /// 数据集。
- public static DataSet ToListSet(this T o, bool generic = true)
- {
- if (o is IEnumerable)
- {
- return ListToDataSet(o as IEnumerable, generic);
- }
- else
- {
- return ListToDataSet(new T[] { o }, generic);
- }
- }
-
- ///
- /// 将可序列化实例转换为XmlDocument。
- ///
- /// 实例类型。
- /// 实例。
- /// XmlDocument。
- public static XmlDocument ToXmlDocument(this T o)
- {
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.InnerXml = o.ToListSet().GetXml();
- return xmlDocument;
- }
-
- ///
- /// 将集合转换为数据集。
- ///
- /// 集合。
- /// 转换的元素类型。
- /// 是否生成泛型数据集。
- /// 转换后的数据集。
- private static DataSet ListToDataSet(IEnumerable list, Type t, bool generic)
- {
- DataSet ds = new DataSet("Data");
- if (t == null)
- {
- if (list != null)
- {
- foreach (var i in list)
- {
- if (i == null)
- {
- continue;
- }
- t = i.GetType();
- break;
- }
- }
- if (t == null)
- {
- return ds;
- }
- }
- ds.Tables.Add(t.Name);
- //如果集合中元素为DataSet扩展涉及到的基本类型时,进行特殊转换。
- if (t.IsValueType || t == typeof(string))
- {
- ds.Tables[0].TableName = "Info";
- ds.Tables[0].Columns.Add(t.Name);
- if (list != null)
- {
- foreach (var i in list)
- {
- DataRow addRow = ds.Tables[0].NewRow();
- addRow[t.Name] = i;
- ds.Tables[0].Rows.Add(addRow);
- }
- }
- return ds;
- }
- //处理模型的字段和属性。
- var fields = t.GetFields();
- var properties = t.GetProperties();
- foreach (var j in fields)
- {
- if (!ds.Tables[0].Columns.Contains(j.Name))
- {
- if (generic)
- {
- ds.Tables[0].Columns.Add(j.Name, j.FieldType);
- }
- else
- {
- ds.Tables[0].Columns.Add(j.Name);
- }
- }
- }
- foreach (var j in properties)
- {
- if (!ds.Tables[0].Columns.Contains(j.Name))
- {
- if (generic)
- {
- ds.Tables[0].Columns.Add(j.Name, j.PropertyType);
- }
- else
- {
- ds.Tables[0].Columns.Add(j.Name);
- }
- }
- }
- if (list == null)
- {
- return ds;
- }
- //读取list中元素的值。
- foreach (var i in list)
- {
- if (i == null)
- {
- continue;
- }
- DataRow addRow = ds.Tables[0].NewRow();
- foreach (var j in fields)
- {
- MemberExpression field = Expression.Field(Expression.Constant(i), j.Name);
- LambdaExpression lambda = Expression.Lambda(field, new ParameterExpression[] { });
- Delegate func = lambda.Compile();
- object value = func.DynamicInvoke();
- addRow[j.Name] = value;
- }
- foreach (var j in properties)
- {
- MemberExpression property = Expression.Property(Expression.Constant(i), j);
- LambdaExpression lambda = Expression.Lambda(property, new ParameterExpression[] { });
- Delegate func = lambda.Compile();
- object value = func.DynamicInvoke();
- addRow[j.Name] = value;
- }
- ds.Tables[0].Rows.Add(addRow);
- }
- return ds;
- }
-
- ///
- /// 将集合转换为数据集。
- ///
- /// 转换的元素类型。
- /// 集合。
- /// 是否生成泛型数据集。
- /// 数据集。
- private static DataSet ListToDataSet(IEnumerable list, bool generic)
- {
- return ListToDataSet(list, typeof(T), generic);
- }
-
- ///
- /// 将集合转换为数据集。
- ///
- /// 集合。
- /// 是否转换为字符串形式。
- /// 转换后的数据集。
- private static DataSet ListToDataSet(IEnumerable list, bool generic)
- {
- return ListToDataSet(list, null, generic);
- }
-
- ///
- /// 获取DataSet第一表,第一行,第一列的值。
- ///
- /// DataSet数据集。
- /// 值。
- public static object GetData(this DataSet ds)
- {
- if (
- ds == null
- || ds.Tables.Count == 0
- )
- {
- return string.Empty;
- }
- else
- {
- return ds.Tables[0].GetData();
- }
- }
-
- ///
- /// 获取DataTable第一行,第一列的值。
- ///
- /// DataTable数据集表。
- /// 值。
- public static object GetData(this DataTable dt)
- {
- if (
- dt.Columns.Count == 0
- || dt.Rows.Count == 0
- )
- {
- return string.Empty;
- }
- else
- {
- return dt.Rows[0][0];
- }
- }
-
- ///
- /// 获取DataSet第一个匹配columnName的值。
- ///
- /// 数据集。
- /// 列名。
- /// 值。
- public static object GetData(this DataSet ds, string columnName)
- {
- if (
- ds == null
- || ds.Tables.Count == 0
- )
- {
- return string.Empty;
- }
- foreach (DataTable dt in ds.Tables)
- {
- object o = dt.GetData(columnName);
- if (!string.IsNullOrEmpty(o.ToString()))
- {
- return o;
- }
- }
- return string.Empty;
- }
-
- ///
- /// 获取DataTable第一个匹配columnName的值。
- ///
- /// 数据表。
- /// 列名。
- /// 值。
- public static object GetData(this DataTable dt, string columnName)
- {
- if (string.IsNullOrEmpty(columnName))
- {
- return GetData(dt);
- }
- if (
- dt.Columns.Count == 0
- || dt.Columns.IndexOf(columnName) == -1
- || dt.Rows.Count == 0
- )
- {
- return string.Empty;
- }
- return dt.Rows[0][columnName];
- }
-
- ///
- /// 将object转换为string类型信息。
- ///
- /// object。
- /// 默认值。
- /// string。
- public static string ToString(this object o, string t)
- {
- string info = string.Empty;
- if (o == null)
- {
- info = t;
- }
- else
- {
- info = o.ToString();
- }
- return info;
- }
-
- ///
- /// 将DateTime?转换为string类型信息。
- ///
- /// DateTime?。
- /// 标准或自定义日期和时间格式的字符串。
- /// 默认值。
- /// string。
- public static string ToString(this DateTime? o, string format, string t)
- {
- string info = string.Empty;
- if (o == null)
- {
- info = t;
- }
- else
- {
- info = o.Value.ToString(format);
- }
- return info;
- }
-
- ///
- /// 将TimeSpan?转换为string类型信息。
- ///
- /// TimeSpan?。
- /// 标准或自定义时间格式的字符串。
- /// 默认值。
- /// string。
- public static string ToString(this TimeSpan? o, string format, string t)
- {
- string info = string.Empty;
- if (o == null)
- {
- info = t;
- }
- else
- {
- info = o.Value.ToString(format);
- }
- return info;
- }
-
- ///
- /// 将object转换为截取后的string类型信息。
- ///
- /// object。
- /// 此实例中子字符串的起始字符位置(从零开始)。
- /// 子字符串中的字符数。
- /// 后缀。如果没有截取则不添加。
- /// 截取后的string类型信息。
- public static string ToSubString(this object o, int startIndex, int length, string suffix = null)
- {
- string inputString = o.ToString(string.Empty);
- startIndex = Math.Max(startIndex, 0);
- startIndex = Math.Min(startIndex, (inputString.Length - 1));
- length = Math.Max(length, 1);
- if (startIndex + length > inputString.Length)
- {
- length = inputString.Length - startIndex;
- }
- if (inputString.Length == startIndex + length)
- {
- return inputString;
- }
- else
- {
- return inputString.Substring(startIndex, length) + suffix;
- }
- }
-
- ///
- /// 将object转换为byte类型信息。
- ///
- /// object。
- /// 默认值。
- /// byte。
- public static byte ToByte(this object o, byte t = default(byte))
- {
- byte info;
- if (!byte.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- public static byte[] ToBytes(this object obj)
- {
- if (obj == null)
- return null;
- var bf = new BinaryFormatter();
- using (var ms = new MemoryStream())
- {
- bf.Serialize(ms, obj);
- return ms.ToArray();
- }
- }
-
- public static object ToObject(this byte[] source)
- {
- using (var memStream = new MemoryStream())
- {
- var bf = new BinaryFormatter();
- memStream.Write(source, 0, source.Length);
- memStream.Seek(0, SeekOrigin.Begin);
- var obj = bf.Deserialize(memStream);
- return obj;
- }
- }
-
- ///
- /// 将object转换为char类型信息。
- ///
- /// object。
- /// 默认值。
- /// char。
- public static char ToChar(this object o, char t = default(char))
- {
- char info;
- if (!char.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为int类型信息。
- ///
- /// object。
- /// 默认值。
- /// int。
- public static int ToInt(this object o, int t = default(int))
- {
- int info;
- if (!int.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为double类型信息。
- ///
- /// object。
- /// 默认值。
- /// double。
- public static double ToDouble(this object o, double t = default(double))
- {
- double info;
- if (!double.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为decimal类型信息。
- ///
- /// object。
- /// 默认值。
- /// decimal。
- public static decimal ToDecimal(this object o, decimal t = default(decimal))
- {
- decimal info;
- if (!decimal.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为float类型信息。
- ///
- /// object。
- /// 默认值。
- /// float。
- public static float ToFloat(this object o, float t = default(float))
- {
- float info;
- if (!float.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为long类型信息。
- ///
- /// object。
- /// 默认值。
- /// long。
- public static long ToLong(this object o, long t = default(long))
- {
- long info;
- if (!long.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为bool类型信息。
- ///
- /// object。
- /// 默认值。
- /// bool。
- public static bool ToBool(this object o, bool t = default(bool))
- {
- bool info;
- if (!bool.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为sbyte类型信息。
- ///
- /// object。
- /// 默认值。
- /// sbyte。
- public static sbyte ToSbyte(this object o, sbyte t = default(sbyte))
- {
- sbyte info;
- if (!sbyte.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为short类型信息。
- ///
- /// object。
- /// 默认值。
- /// short。
- public static short ToShort(this object o, short t = default(short))
- {
- short info;
- if (!short.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为ushort类型信息。
- ///
- /// object。
- /// 默认值。
- /// ushort。
- public static ushort ToUShort(this object o, ushort t = default(ushort))
- {
- ushort info;
- if (!ushort.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为ulong类型信息。
- ///
- /// object。
- /// 默认值。
- /// ulong。
- public static ulong ToULong(this object o, ulong t = default(ulong))
- {
- ulong info;
- if (!ulong.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为Enum[T]类型信息。
- ///
- /// object。
- /// 默认值。
- /// Enum[T]。
- public static T ToEnum(this object o, T t = default(T))
- where T : struct
- {
- T info;
- if (!Enum.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为DateTime类型信息。
- ///
- /// object。
- /// 默认值。
- /// DateTime。
- public static DateTime ToDateTime(this object o, DateTime t = default(DateTime))
- {
- if (t == default(DateTime))
- {
- t = new DateTime(1753, 1, 1);
- }
- DateTime info;
- if (!DateTime.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为TimeSpan类型信息。
- ///
- /// object。
- /// 默认值。
- /// TimeSpan。
- public static TimeSpan ToTimeSpan(this object o, TimeSpan t = default(TimeSpan))
- {
- if (t == default(TimeSpan))
- {
- t = new TimeSpan(0, 0, 0);
- }
- TimeSpan info;
- if (!TimeSpan.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- ///
- /// 将object转换为Guid类型信息。
- ///
- /// object。
- /// 默认值。
- /// Guid。
- public static Guid ToGuid(this object o, Guid t = default(Guid))
- {
- Guid info;
- if (!Guid.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- return info;
- }
-
- private static Regex BoolRegex = new Regex("(?(true|false))", RegexOptions.IgnoreCase | RegexOptions.Singleline);
-
- ///
- /// 从object中获取bool类型信息。
- ///
- /// object。
- /// bool。
- public static bool? GetBool(this object o)
- {
- bool info;
- if (!bool.TryParse(BoolRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return info;
- }
-
- private static Regex IntRegex = new Regex("(?-?\\d+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
-
- ///
- /// 从object中获取int类型信息。
- ///
- /// object。
- /// int。
- public static int? GetInt(this object o)
- {
- int info;
- if (!int.TryParse(IntRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return info;
- }
-
- private static Regex DecimalRegex = new Regex("(?-?\\d+(\\.\\d+)?)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
-
- ///
- /// 从object中获取decimal类型信息。
- ///
- /// object。
- /// decimal。
- public static decimal? GetDecimal(this object o)
- {
- decimal info;
- if (!decimal.TryParse(DecimalRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return info;
- }
-
- ///
- /// 从object中获取double类型信息。
- ///
- /// object。
- /// double。
- public static double? GetDouble(this object o)
- {
- double info;
- if (!double.TryParse(DecimalRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return info;
- }
-
- ///
- /// 从object中获取正数信息。
- ///
- /// object。
- /// decimal。
- public static decimal? GetPositiveNumber(this object o)
- {
- decimal info;
- if (!decimal.TryParse(DecimalRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return Math.Abs(info);
- }
-
- private static Regex DateTimeRegex = new Regex("(?(((\\d+)[/年-](0?[13578]|1[02])[/月-](3[01]|[12]\\d|0?\\d)[日]?)|((\\d+)[/年-](0?[469]|11)[/月-](30|[12]\\d|0?\\d)[日]?)|((\\d+)[/年-]0?2[/月-](2[0-8]|1\\d|0?\\d)[日]?))(\\s((2[0-3]|[0-1]\\d)):[0-5]\\d:[0-5]\\d)?)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
-
- ///
- /// 从object中获取DateTime?类型信息。
- ///
- /// object。
- /// DateTime?。
- public static DateTime? GetDateTime(this object o)
- {
- DateTime info;
- if (!DateTime.TryParse(DateTimeRegex.Match(o.ToString(string.Empty)).Groups["info"].Value.Replace("年", "-").Replace("月", "-").Replace("/", "-").Replace("日", ""), out info))
- {
- return null;
- }
- return info;
- }
-
- private static Regex TimeSpanRegex = new Regex("(?-?(\\d+\\.(([0-1]\\d)|(2[0-3])):[0-5]\\d:[0-5]\\d)|((([0-1]\\d)|(2[0-3])):[0-5]\\d:[0-5]\\d)|(\\d+))", RegexOptions.IgnoreCase | RegexOptions.Singleline);
-
- ///
- /// 从object中获取TimeSpan?类型信息。
- ///
- /// object。
- /// TimeSpan?。
- public static TimeSpan? GetTimeSpan(this object o)
- {
- TimeSpan info;
- if (!TimeSpan.TryParse(TimeSpanRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return info;
- }
-
- private static Regex GuidRegex = new Regex("(?\\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\\}{0,1})", RegexOptions.IgnoreCase | RegexOptions.Singleline);
-
- ///
- /// 从object中获取Guid?类型信息。
- ///
- /// object。
- /// Guid?。
- public static Guid? GetGuid(this object o)
- {
- Guid info;
- if (!Guid.TryParse(GuidRegex.Match(o.ToString(string.Empty)).Groups["info"].Value, out info))
- {
- return null;
- }
- return info;
- }
-
- ///
- /// 将object转换为SqlServer中的DateTime?类型信息。
- ///
- /// object。
- /// 默认值。
- /// DateTime?。
- public static DateTime? GetSqlDateTime(this object o, DateTime t = default(DateTime))
- {
- DateTime info;
- if (!DateTime.TryParse(o.ToString(string.Empty), out info))
- {
- info = t;
- }
- if (info < new DateTime(1753, 1, 1) || info > new DateTime(9999, 12, 31))
- {
- return null;
- }
- return info;
- }
-
- ///
- /// 读取XElement节点的文本内容。
- ///
- /// XElement节点。
- /// 默认值。
- /// 文本内容。
- public static string Value(this XElement xElement, string t = default(string))
- {
- if (xElement == null)
- {
- return t;
- }
- else
- {
- return xElement.Value;
- }
- }
-
- ///
- /// 获取与指定键相关的值。
- ///
- /// 键类型。
- /// 值类型。
- /// 表示键/值对象的泛型集合。
- /// 键。
- /// 默认值。
- /// 值。
- public static TValue GetValue(this IDictionary dictionary, TKey key, TValue t = default(TValue))
- {
- TValue value = default(TValue);
- if (dictionary == null || key == null)
- {
- return t;
- }
- if (!dictionary.TryGetValue(key, out value))
- {
- value = t;
- }
- return value;
- }
-
- ///
- /// 获取与指定键相关或者第一个的值。
- ///
- /// 键类型。
- /// 值类型。
- /// 表示键/值对象的泛型集合。
- /// 键。
- /// 默认值。
- /// 值。
- public static TValue GetFirstOrDefaultValue(this IDictionary dictionary, TKey key, TValue t = default(TValue))
- {
- TValue value = default(TValue);
- if (dictionary == null || key == null)
- {
- return t;
- }
- if (!dictionary.TryGetValue(key, out value))
- {
- if (dictionary.Count() == 0)
- {
- value = t;
- }
- else
- {
- value = dictionary.FirstOrDefault().Value;
- }
- }
- return value;
- }
-
- ///
- /// 获取具有指定 System.Xml.Linq.XName 的第一个(按文档顺序)子元素。
- ///
- /// XContainer。
- /// 要匹配的 System.Xml.Linq.XName。
- /// 是否返回同名默认值。
- /// 与指定 System.Xml.Linq.XName 匹配的 System.Xml.Linq.XElement,或者为 null。
- public static XElement Element(this XContainer xContainer, XName xName, bool t)
- {
- XElement info;
- if (xContainer == null)
- {
- info = null;
- }
- else
- {
- info = xContainer.Element(xName);
- }
- if (t && info == null)
- {
- info = new XElement(xName);
- }
- return info;
- }
-
- ///
- /// 按文档顺序返回此元素或文档的子元素集合。
- ///
- /// XContainer。
- /// 是否返回非空默认值。
- /// System.Xml.Linq.XElement 的按文档顺序包含此System.Xml.Linq.XContainer 的子元素,或者非空默认值。
- public static IEnumerable Elements(this XContainer xContainer, bool t)
- {
- IEnumerable info;
- if (xContainer == null)
- {
- info = null;
- }
- else
- {
- info = xContainer.Elements();
- }
- if (t && info == null)
- {
- info = new List();
- }
- return info;
- }
-
- ///
- /// 按文档顺序返回此元素或文档的经过筛选的子元素集合。集合中只包括具有匹配 System.Xml.Linq.XName 的元素。
- ///
- /// XContainer。
- /// 要匹配的 System.Xml.Linq.XName。
- /// 是否返回非空默认值。
- /// System.Xml.Linq.XElement 的按文档顺序包含具有匹配System.Xml.Linq.XName 的 System.Xml.Linq.XContainer 的子级,或者非空默认值。
- public static IEnumerable Elements(this XContainer xContainer, XName xName, bool t)
- {
- IEnumerable info;
- if (xContainer == null)
- {
- info = null;
- }
- else
- {
- info = xContainer.Elements(xName);
- }
- if (t && info == null)
- {
- info = new List();
- }
- return info;
- }
-
- ///
- /// 删除html标签。
- ///
- /// 输入的字符串。
- /// 没有html标签的字符串。
- public static string RemoveHTMLTags(this string html)
- {
- return Regex.Replace(Regex.Replace(Regex.Replace((html ?? string.Empty).Replace(" ", " ").Replace("\r\n", " ").Replace("\n", " ").Replace("\r", " ").Replace("\t", " "), "<\\/?[^>]+>", "\r\n"), "(\r\n)+", "\r\n"), "(\\s)+", " ").Trim();
- }
-
- ///
- /// 字符串转换为文件名。
- ///
- /// 字符串。
- /// 文件名。
- public static string ToFileName(this string s)
- {
- return Regex.Replace(s.ToString(string.Empty), @"[\\/:*?<>|]", "_").Replace("\t", " ").Replace("\r\n", " ").Replace("\"", " ");
- }
-
- ///
- /// 获取星期一的日期。
- ///
- /// 日期。
- /// 星期一的日期。
- public static DateTime? GetMonday(this DateTime dateTime)
- {
- return dateTime.AddDays(-1 * (int)dateTime.AddDays(-1).DayOfWeek).ToString("yyyy-MM-dd").GetDateTime();
- }
-
- ///
- /// 获取默认非空字符串。
- ///
- /// 首选默认非空字符串。
- /// 依次非空字符串可选项。
- /// 默认非空字符串。若无可选项则返回string.Empty。
- public static string DefaultStringIfEmpty(this string s, params string[] args)
- {
- if (string.IsNullOrEmpty(s))
- {
- foreach (string i in args)
- {
- if (!string.IsNullOrEmpty(i) && !string.IsNullOrEmpty(i.Trim()))
- {
- return i;
- }
- }
- }
- return (s ?? string.Empty);
- }
-
- ///
- /// 对 URL 字符串进行编码。
- ///
- /// 要编码的文本。
- /// 匹配要编码的文本。
- /// 指定编码方案的 System.Text.Encoding 对象。
- /// 一个已编码的字符串。
- public static string ToUrlEncodeString(this string s, Regex regex = default(Regex), Encoding encoding = null)
- {
- if (encoding == null)
- {
- encoding = Encoding.UTF8;
- }
- if (regex == null)
- {
- return HttpUtility.UrlEncode(s, encoding);
- }
- List l = new List();
- foreach (char i in s)
- {
- string t = i.ToString();
- l.Add(regex.IsMatch(t) ? HttpUtility.UrlEncode(t, encoding) : t);
- }
- return string.Join(string.Empty, l);
- }
-
- ///
- /// 对 URL 字符串进行编码。
- ///
- /// 要编码的文本。
- /// 匹配要编码的文本。
- /// 指定编码方案的 System.Text.Encoding 对象。
- /// 一个已编码的字符串。
- public static string ToUrlEncodeString(this string s, string regex, Encoding encoding = null)
- {
- return ToUrlEncodeString(s, new Regex(regex), encoding);
- }
-
- ///
- /// 将日期转换为UNIX时间戳字符串
- ///
- ///
- ///
- public static string ToUnixTimeStamp(this DateTime date)
- {
- DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1));
- string timeStamp = date.Subtract(startTime).Ticks.ToString();
- return timeStamp.Substring(0, timeStamp.Length - 7);
- }
-
- private static Regex MobileRegex = new Regex("^1[3|4|5|7|8][0-9]\\d{4,8}$");
- private static Regex EmailRegex = new Regex("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})$");
-
- ///
- /// 判断当前字符串是否是移动电话号码
- ///
- ///
- ///
- public static bool IsMobile(this string mobile)
- {
- return MobileRegex.IsMatch(mobile);
- }
-
- ///
- /// 判断当前字符串是否为邮箱
- ///
- ///
- ///
- public static bool IsEmail(this string email)
- {
- return EmailRegex.IsMatch(email);
- }
- }
-
- ///
- /// 结果。
- ///
- /// 结果返回值类型。
- public class Result
- {
- ///
- /// 标记。
- ///
- public Flag Flag { get; set; }
-
- ///
- /// 返回值。
- ///
- public T Return { get; set; }
-
- ///
- /// 消息。
- ///
- public string Message { get; set; }
-
- ///
- /// 异常。
- ///
- public Exception Exception { get; set; }
-
- ///
- /// 时间。
- ///
- public DateTime DateTime { get; set; }
-
- ///
- /// 整型数据。
- ///
- public int Int { get; set; }
-
- ///
- /// 浮点数据。
- ///
- public decimal Decimal { get; set; }
-
- ///
- /// 布尔数据。
- ///
- public bool Bool { get; set; }
-
- ///
- /// 对象。
- ///
- public object Object { get; set; }
- }
-
- ///
- /// 标记。
- ///
- public enum Flag
- {
- ///
- /// 默认。
- ///
- Default,
-
- ///
- /// 真。
- ///
- True,
-
- ///
- /// 假。
- ///
- False
- }
-}
\ No newline at end of file
diff --git a/samples/Common/DDD.Core/DDD.Core.Extensions/StringExtensions.cs b/samples/Common/DDD.Core/DDD.Core.Extensions/StringExtensions.cs
deleted file mode 100644
index b1c191880..000000000
--- a/samples/Common/DDD.Core/DDD.Core.Extensions/StringExtensions.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-using System;
-using System.Text.RegularExpressions;
-
-namespace DDD.Core.Extensions
-{
- public static class StringExtensions
- {
- public static object ParseTo(this string str, string type)
- {
- switch (type)
- {
- case "System.Boolean":
- return ToBoolean(str);
- case "System.SByte":
- return ToSByte(str);
- case "System.Byte":
- return ToByte(str);
- case "System.UInt16":
- return ToUInt16(str);
- case "System.Int16":
- return ToInt16(str);
- case "System.uInt32":
- return ToUInt32(str);
- case "System.Int32":
- return str.ToInt32();
- case "System.UInt64":
- return ToUInt64(str);
- case "System.Int64":
- return ToInt64(str);
- case "System.Single":
- return ToSingle(str);
- case "System.Double":
- return ToDouble(str);
- case "System.Decimal":
- return ToDecimal(str);
- case "System.DateTime":
- return ToDateTime(str);
- case "System.Guid":
- return ToGuid(str);
- }
- throw new NotSupportedException(string.Format("The string of \"{0}\" can not be parsed to {1}", str, type));
- }
-
- public static sbyte? ToSByte(this string value)
- {
- sbyte value2;
- if (sbyte.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static byte? ToByte(this string value)
- {
- byte value2;
- if (byte.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static ushort? ToUInt16(this string value)
- {
- ushort value2;
- if (ushort.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static short? ToInt16(this string value)
- {
- short value2;
- if (short.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static uint? ToUInt32(this string value)
- {
- uint value2;
- if (uint.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static ulong? ToUInt64(this string value)
- {
- ulong value2;
- if (ulong.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static long? ToInt64(this string value)
- {
- long value2;
- if (long.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static float? ToSingle(this string value)
- {
- float value2;
- if (float.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static double? ToDouble(this string value)
- {
- double value2;
- if (double.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static decimal? ToDecimal(this string value)
- {
- decimal value2;
- if (decimal.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static bool? ToBoolean(this string value)
- {
- bool value2;
- if (bool.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static T? ToEnum(this string str) where T : struct
- {
- T t;
- if (Enum.TryParse(str, true, out t) && Enum.IsDefined(typeof(T), t))
- {
- return t;
- }
- return null;
- }
-
- public static Guid? ToGuid(this string str)
- {
- Guid value;
- if (Guid.TryParse(str, out value))
- {
- return value;
- }
- return null;
- }
-
- public static DateTime? ToDateTime(this string value)
- {
- DateTime value2;
- if (DateTime.TryParse(value, out value2))
- {
- return value2;
- }
- return null;
- }
-
- public static int? ToInt32(this string input)
- {
- if (string.IsNullOrEmpty(input))
- {
- return null;
- }
- int value;
- if (int.TryParse(input, out value))
- {
- return value;
- }
- return null;
- }
-
- ///
- /// 替换空格字符
- ///
- ///
- /// 替换为该字符
- /// 替换后的字符串
- public static string ReplaceWhitespace(this string input, string replacement = "")
- {
- return string.IsNullOrEmpty(input) ? null : Regex.Replace(input, "\\s", replacement, RegexOptions.Compiled);
- }
-
- ///
- /// 返回一个值,该值指示指定的 String 对象是否出现在此字符串中。
- ///
- ///
- /// 要搜寻的字符串。
- /// 指定搜索规则的枚举值之一。
- /// 如果 value 参数出现在此字符串中则为 true;否则为 false。
- public static bool Contains(this string source, string value,
- StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)
- {
- return source.IndexOf(value, comparisonType) >= 0;
- }
-
- ///
- /// 清除 Html 代码,并返回指定长度的文本。(连续空行或空格会被替换为一个)
- ///
- ///
- /// 返回的文本长度(为0返回所有文本)
- ///
- public static string StripHtml(this string text, int maxLength = 0)
- {
- if (string.IsNullOrEmpty(text)) return string.Empty;
- text = text.Trim();
-
- text = Regex.Replace(text, "[\\r\\n]{2,}", "<&rn>"); //替换回车和换行为<&rn>,防止下一行代码替换空格的时候被替换掉
- text = Regex.Replace(text, "[\\s]{2,}", " "); //替换 2 个以上的空格为 1 个
- text = Regex.Replace(text, "(<&rn>)+", "\n"); //还原 <&rn> 为 \n
- text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " "); //
-
- text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n"); //
- text = Regex.Replace(text, "<(.|\n)+?>", " ", RegexOptions.IgnoreCase); //any other tags
-
- if (maxLength > 0 && text.Length > maxLength)
- text = text.Substring(0, maxLength);
-
- return text;
- }
- }
-}
diff --git a/samples/Common/DDD.Core/DDD.Core.csproj b/samples/Common/DDD.Core/DDD.Core.csproj
deleted file mode 100644
index 3cfd4024c..000000000
--- a/samples/Common/DDD.Core/DDD.Core.csproj
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- netstandard2.0
-
-
-
-
-
-
-
-
-
-
-
-
- C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.configuration.abstractions\2.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll
-
-
- C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.fileproviders.physical\2.0.0\lib\netstandard2.0\Microsoft.Extensions.FileProviders.Physical.dll
-
-
-
-
diff --git a/samples/Common/DDD.Core/IAggregate.cs b/samples/Common/DDD.Core/IAggregate.cs
deleted file mode 100644
index 0edd419b1..000000000
--- a/samples/Common/DDD.Core/IAggregate.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-
-namespace DDD.Core
-{
-
- /// Represents an aggregate root.
- ///
- public abstract class IAggregate: IDBModel
- {
- [Key]
- public virtual Guid KeyId { get; set; }
- ///
- /// 归属公司
- ///
- public virtual Guid CorporationKeyId { get; set; }
- public DateTime CreateTime { get; set; }
- public Guid CreateUserKeyId { get; set; }
- public DateTime UpdateTime { get; set; }
- public Guid UpdateUserKeyId { get; set; }
- public bool IsDelete { get; set; }
- public int Version { get; set; }
-
- public string Name { get; set; }
-
- public string No { get; set; }
- }
-}
diff --git a/samples/Common/DDD.Core/IQueryOnlyRepository.cs b/samples/Common/DDD.Core/IQueryOnlyRepository.cs
deleted file mode 100644
index 0d17da9b7..000000000
--- a/samples/Common/DDD.Core/IQueryOnlyRepository.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Text;
-
-namespace DDD.Core
-{
- ///
- /// 只读的查询资源库接口
- ///
- public interface IQueryOnlyRepository where T : class,IDBModel
- {
-
- int Count(Expression> @where = null);
-
- bool Exist(Expression> @where = null);
- bool Exist(Expression> @where = null, params Expression>[] includes);
- int ExecuteSqlWithNonQuery(string sql, params object[] parameters);
- T GetSingle(TKey key);
- T GetSingle(TKey key, params Expression>[] includes);
- T GetSingle(Expression> @where = null);
- T GetSingle(Expression> @where = null, params Expression>[] includes);
- IQueryable Get(Expression> @where = null);
- IQueryable Get(Expression> @where = null, params Expression>[] includes);
- IEnumerable GetByPagination(Expression> @where, int pageSize, int pageIndex,
- Expression>[] include,bool asc = true, params Func[] @orderby);
-
- IList SqlQuery(string sql, params object[] parameters) where TView : class, new();
-
-
- }
-}
diff --git a/samples/Common/DDD.Core/IRepository.cs b/samples/Common/DDD.Core/IRepository.cs
deleted file mode 100644
index 8d0d5ac01..000000000
--- a/samples/Common/DDD.Core/IRepository.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System;
-
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Text;
-
-namespace DDD.Core
-{
- public interface IDBModel
- {
- TKey KeyId { get; set; }
-
- TKey CorporationKeyId { get; set; }
- DateTime CreateTime { get; set; }
- TKey CreateUserKeyId { get; set; }
- DateTime UpdateTime { get; set; }
- TKey UpdateUserKeyId { get; set; }
- bool IsDelete { get; set; }
- int Version { get; set; }
-
-
- }
- public interface IRepository: IUnitOfWork where T : IAggregate
- {
- void Add(T aggregate); //where T : IAggregate;
- T FindBy(TKey key); //where T : IAggregate;
- void Update(T aggregate); //where T : IAggregate;
- void Delete(TKey key);
-
-
- }
-}
diff --git a/samples/Common/DDD.Core/IUnitOfWork.cs b/samples/Common/DDD.Core/IUnitOfWork.cs
deleted file mode 100644
index d687b586b..000000000
--- a/samples/Common/DDD.Core/IUnitOfWork.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-
-namespace DDD.Core
-{
- public interface IUnitOfWork: IDisposable
- {
- #region for transaction
- ///
- /// 提交一个聚合内的所有变更
- ///
- ///
- /// If the entity have fixed properties and any optimistic concurrency problem exists,
- /// then an exception is thrown
- ///
- int Commit();
-
-
- #endregion
-
- // int SaveChanges();
- //int SaveChangesAsync();
-
- }
-}
diff --git a/samples/Common/DTO.Core/BasePagedRequestDto.cs b/samples/Common/DTO.Core/BasePagedRequestDto.cs
deleted file mode 100644
index 03a9bbd71..000000000
--- a/samples/Common/DTO.Core/BasePagedRequestDto.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- public class BasePagedRequestDto: BaseRequestDto
- {
- ///
- /// 页码号,从1开始,可空(返回全部记录)
- ///
- public int PageIndex { get; set; }
-
- ///
- /// 每页显示的记录数,可空(返回全部记录)
- ///
- public int PageSize { get; set; }
- }
-}
diff --git a/samples/Common/DTO.Core/BaseRequestDto.cs b/samples/Common/DTO.Core/BaseRequestDto.cs
deleted file mode 100644
index 9220bf810..000000000
--- a/samples/Common/DTO.Core/BaseRequestDto.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- ///
- /// 接口参数 dto抽象基类
- ///
- public abstract class BaseRequestDto : BaseDto
- {
- ///
- /// 服务访问身份信息
- ///
- public TokenDto Identify { get; set; }
-
-
- }
- ///
- /// 实体的增、删、改
- ///
- public class EntityCUDReq : BaseRequestDto
- {
- public Guid? KeyId { get; set; }
- }
- ///
- /// 实体上的命令
- ///
- public class EntityCMDReq : BaseRequestDto
- {
-
- }
-
- ///
- /// 简单的请求
- /// 参数不确定
- ///
- public class CommonCMDReq : BaseRequestDto
- {
- public string CommonCMD { get; set; }
- }
-
-
- ///
- /// 树形列表的搜索
- ///
- public class BaseTreeSearchReq : BaseRequestDto
- {
- ///
- /// 搜索条件
- ///
- public string SearchKey { get; set; }
-
- }
-}
diff --git a/samples/Common/DTO.Core/BaseResponseDto.cs b/samples/Common/DTO.Core/BaseResponseDto.cs
deleted file mode 100644
index 4cada02d1..000000000
--- a/samples/Common/DTO.Core/BaseResponseDto.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- public class BaseResponseDto:BaseDto
- {
- ///
- /// 请求结果,请求成功/失败
- ///
- public bool OperateFlag { get; set; }
-
- ///
- /// 服务端错误信息
- ///
- public string FlagErrorMsg { get; set; }
-
-
- }
-
- public class BaseTreeResponseDto: BaseResponseDto
- {
- public List Tree { get; set; }
- }
-
- public class BaseTreeDto
- {
- public string Id { get; set; }
- public string PId { get; set; }
- public string Name { get; set; }
- }
-
- public class BaseListResponseDto : BaseResponseDto
- {
- public dynamic Result { get; set; }
- }
-
-}
diff --git a/samples/Common/DTO.Core/BaseSearchCriteriaDto.cs b/samples/Common/DTO.Core/BaseSearchCriteriaDto.cs
deleted file mode 100644
index a9e983098..000000000
--- a/samples/Common/DTO.Core/BaseSearchCriteriaDto.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- public abstract class BaseSearchCriteriaDto : BaseDto
- {
-
- }
-}
diff --git a/samples/Common/DTO.Core/BaseSortCriteriaDto.cs b/samples/Common/DTO.Core/BaseSortCriteriaDto.cs
deleted file mode 100644
index bb0b01142..000000000
--- a/samples/Common/DTO.Core/BaseSortCriteriaDto.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- ///
- /// 搜索条件排序基类Dto。
- ///
- public abstract class BaseSortCriteriaDto : BaseDto
- {
- ///
- /// 创建时间
- ///
-
- public static readonly string CREATE_TIME = "CreateTime";
-
- ///
- /// 修改时间
- ///
-
- public static readonly string UPDATE_TIME = "UpdateTime";
-
- ///
- /// 正向/反向排序
- ///
-
- public bool Ascending { set; get; }
-
- ///
- /// 排序名称
- ///
-
- public string SortPropertyName { set; get; }
- }
-}
diff --git a/samples/Common/DTO.Core/DTO.Core.csproj b/samples/Common/DTO.Core/DTO.Core.csproj
deleted file mode 100644
index 5766db614..000000000
--- a/samples/Common/DTO.Core/DTO.Core.csproj
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- netcoreapp2.0
-
-
-
diff --git a/samples/Common/DTO.Core/IdentifyDto.cs b/samples/Common/DTO.Core/IdentifyDto.cs
deleted file mode 100644
index 61a276b6e..000000000
--- a/samples/Common/DTO.Core/IdentifyDto.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- public abstract class BaseDto
- {
-
- }
- public class TokenDto: BaseDto
- {
- ///
- /// 员工编号
- ///
- public string Token { get; set; }
- public Guid CorporationKeyId { get; set; }
-
- }
- public class IdentifyDto : BaseDto
- {
- ///
- /// 当前用户keyId
- ///
-
- public Guid UserKeyId { get; set; }
-
- ///
- /// 当前用户名
- ///
-
- public string UserName { get; set; }
-
- ///
- /// 当前用户部门keyId
- ///
-
- public Guid DepartmentKeyId { get; set; }
-
- ///
- /// 部门编号
- ///
-
- public string DepartmentNo { get; set; }
-
- ///
- /// 当前用户部门名称
- ///
-
- public string DepartmentName { get; set; }
-
- ///
- /// 当前用户所属公司keyId
- ///
-
- public Guid CorporationKeyId { get; set; }
-
-
- ///
- /// 用户登录方式
- ///
-
- public string LoginType { get; set; }
-
- ///
- /// 用户账号
- ///
-
- public string UserNo { get; set; }
-
- ///
- /// 当前用户手机号
- ///
-
- public string UserPhone { get; set; }
-
- ///
- /// 角色code
- ///
-
- public string RoleCode { get; set; }
-
- ///
- /// 角色名称
- ///
-
- public string RoleName { get; set; }
- }
- }
diff --git a/samples/Common/DTO.Core/KeyIdReq.cs b/samples/Common/DTO.Core/KeyIdReq.cs
deleted file mode 100644
index aebc1b302..000000000
--- a/samples/Common/DTO.Core/KeyIdReq.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- public class KeyIdReq:BaseRequestDto
- {
- public Guid KeyId { get; set; }
- }
-}
diff --git a/samples/Common/DTO.Core/OperateResultDto.cs b/samples/Common/DTO.Core/OperateResultDto.cs
deleted file mode 100644
index a8a88f3f4..000000000
--- a/samples/Common/DTO.Core/OperateResultDto.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace DTO.Core
-{
- public class OperateResultRsp : BaseResponseDto
- {
- ///
- /// 操作结果
- ///
- public string OperateResult { get; set; }
-
- }
-}
diff --git a/samples/Common/Repository.Dapper.Core/BaseImpQueryOnlyRepository.cs b/samples/Common/Repository.Dapper.Core/BaseImpQueryOnlyRepository.cs
deleted file mode 100644
index 614dbd9a3..000000000
--- a/samples/Common/Repository.Dapper.Core/BaseImpQueryOnlyRepository.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using DDD.Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Text;
-
-namespace Repository.Dapper.Core
-{
- public class BaseImpQueryOnlyRepository : IQueryOnlyRepository where T : class, IDBModel
- {
- public int Count(Expression> where = null)
- {
- throw new NotImplementedException();
- }
-
- public int ExecuteSqlWithNonQuery(string sql, params object[] parameters)
- {
- throw new NotImplementedException();
- }
-
- public bool Exist(Expression> where = null)
- {
- throw new NotImplementedException();
- }
-
- public bool Exist(Expression> where = null, params Expression>[] includes)
- {
- throw new NotImplementedException();
- }
-
- public IQueryable Get(Expression> where = null)
- {
- throw new NotImplementedException();
- }
-
- public IQueryable Get(Expression> where = null, params Expression>[] includes)
- {
- throw new NotImplementedException();
- }
-
- public IEnumerable GetByPagination(Expression> where, int pageSize, int pageIndex, Expression>[] include, bool asc = true, params Func[] orderby)
- {
- throw new NotImplementedException();
- }
-
- public T GetSingle(Guid key)
- {
- throw new NotImplementedException();
- }
-
- public T GetSingle(Guid key, params Expression>[] includes)
- {
- throw new NotImplementedException();
- }
-
- public T GetSingle(Expression> where = null)
- {
- throw new NotImplementedException();
- }
-
- public T GetSingle(Expression> where = null, params Expression>[] includes)
- {
- throw new NotImplementedException();
- }
-
- public IList SqlQuery(string sql, params object[] parameters) where TView : class, new()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/samples/Common/Repository.Dapper.Core/BaseImpRepository.cs b/samples/Common/Repository.Dapper.Core/BaseImpRepository.cs
deleted file mode 100644
index a22e182ad..000000000
--- a/samples/Common/Repository.Dapper.Core/BaseImpRepository.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using DDD.Core;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Repository.Dapper.Core
-{
- public class BaseImpRepository : IRepository where T : IAggregate
- {
- public void Add(T aggregate)
- {
- throw new NotImplementedException();
- }
-
- public int Commit()
- {
- throw new NotImplementedException();
- }
-
- public void Delete(Guid key)
- {
- throw new NotImplementedException();
- }
-
- public void Dispose()
- {
- throw new NotImplementedException();
- }
-
- public T FindBy(Guid key)
- {
- throw new NotImplementedException();
- }
-
- public void Update(T aggregate)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/samples/Common/Repository.Dapper.Core/DapperExtensions.cs b/samples/Common/Repository.Dapper.Core/DapperExtensions.cs
deleted file mode 100644
index 61b4a2146..000000000
--- a/samples/Common/Repository.Dapper.Core/DapperExtensions.cs
+++ /dev/null
@@ -1,567 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using Repository.Dapper.Core.Sql;
-using Repository.Dapper.Core.Mapper;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace Repository.Dapper.Core
-{
- public static class DapperExtensions
- {
- #region other
- private readonly static object _lock = new object();
-
- private static Func _instanceFactory;
- private static IDapperImplementor _instance;
- private static IDapperExtensionsConfiguration _configuration;
-
- ///
- /// Gets or sets the default class mapper to use when generating class maps. If not specified, AutoClassMapper is used.
- /// Repository.Dapper.Core.Configure(Type, IList, ISqlDialect) can be used instead to set all values at once
- ///
- public static Type DefaultMapper
- {
- get
- {
- return _configuration.DefaultMapper;
- }
-
- set
- {
- Configure(value, _configuration.MappingAssemblies, _configuration.Dialect);
- }
- }
-
- ///
- /// Gets or sets the type of sql to be generated.
- /// DapperExtensions.Configure(Type, IList, ISqlDialect) can be used instead to set all values at once
- ///
- public static ISqlDialect SqlDialect
- {
- get
- {
- return _configuration.Dialect;
- }
-
- set
- {
- Configure(_configuration.DefaultMapper, _configuration.MappingAssemblies, value);
- }
- }
-
- ///
- /// Get or sets the Dapper Extensions Implementation Factory.
- ///
- public static Func InstanceFactory
- {
- get
- {
- if (_instanceFactory == null)
- {
- _instanceFactory = config => new DapperImplementor(new SqlGeneratorImpl(config));
- }
-
- return _instanceFactory;
- }
- set
- {
- _instanceFactory = value;
- Configure(_configuration.DefaultMapper, _configuration.MappingAssemblies, _configuration.Dialect);
- }
- }
-
- ///
- /// Gets the Dapper Extensions Implementation
- ///
- private static IDapperImplementor Instance
- {
- get
- {
- if (_instance == null)
- {
- lock (_lock)
- {
- if (_instance == null)
- {
- _instance = InstanceFactory(_configuration);
- }
- }
- }
-
- return _instance;
- }
- }
-
- //static DapperExtensions()
- //{
- // Configure(typeof(AutoClassMapper<>), new List(), new SqlServerDialect());
- //}
-
- ///
- /// Add other assemblies that Dapper Extensions will search if a mapping is not found in the same assembly of the POCO.
- ///
- ///
- public static void SetMappingAssemblies(IList assemblies)
- {
- Configure(_configuration.DefaultMapper, assemblies, _configuration.Dialect);
- }
-
- ///
- /// Configure DapperExtensions extension methods.
- ///
- ///
- ///
- ///
- public static void Configure(IDapperExtensionsConfiguration configuration)
- {
- _instance = null;
- _configuration = configuration;
- }
-
- ///
- /// Configure DapperExtensions extension methods.
- ///
- ///
- ///
- ///
- public static void Configure(Type defaultMapper, IList mappingAssemblies, ISqlDialect sqlDialect)
- {
- Configure(new DapperExtensionsConfiguration(defaultMapper, mappingAssemblies, sqlDialect));
- }
-
- public static void Configure(ISqlDialect sqlDialect, Type defaultMapper = null, IList mappingAssemblies = null)
- {
- defaultMapper = defaultMapper ?? typeof(AutoClassMapper<>);
- mappingAssemblies = mappingAssemblies ?? new List();
- Configure(new DapperExtensionsConfiguration(defaultMapper, mappingAssemblies, sqlDialect));
- }
-
- #endregion
-
- #region Get
- ///
- /// Executes a query for the specified id, returning the data typed as per T
- ///
- public static T Get(this IDbConnection connection, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Get(connection, null, id, transaction, commandTimeout);
-
- public static T Get(this IDbConnection connection, string tableName, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Get(connection, tableName, null, id, transaction, commandTimeout);
-
- public static T Get(this IDbConnection connection, string tableName, string schemaName, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => (T)Instance.Get(connection, id, transaction, commandTimeout, tableName, schemaName, null, null);
-
- public static async Task GetAsync(this IDbConnection connection, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await GetAsync(connection, null, id, transaction, commandTimeout);
-
- public static async Task GetAsync(this IDbConnection connection, string tableName, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await GetAsync(connection, tableName, null, id, transaction, commandTimeout);
-
- public static async Task GetAsync(this IDbConnection connection, string tableName, string schemaName, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await Instance.GetAsync(connection, id, transaction, commandTimeout, tableName, schemaName, null, null);
-
- public static T Get(this IDbConnection connection, IList join, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Get(connection, join, null, id, transaction, commandTimeout);
-
- public static T Get(this IDbConnection connection, IList join, IList alias, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => (T)Instance.Get(connection, id, transaction, commandTimeout, null, null, join, alias);
-
- public static async Task GetAsync(this IDbConnection connection, IList join, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await GetAsync(connection, join, null, id, transaction, commandTimeout);
-
- public static async Task GetAsync(this IDbConnection connection, IList join, IList alias, dynamic id, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await Instance.GetAsync(connection, id, transaction, commandTimeout, null, null, join, alias);
-
- #endregion
-
- #region Insert
- ///
- /// Executes an insert query for the specified entity.
- ///
- public static void Insert(this IDbConnection connection, IEnumerable entities, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Insert(connection, null, entities, transaction, commandTimeout);
-
- public static void Insert(this IDbConnection connection, string tableName, IEnumerable entities, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Insert(connection, tableName, null, entities, transaction, commandTimeout);
-
- public static void Insert(this IDbConnection connection, string tableName, string schemaName, IEnumerable entities, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Instance.Insert(connection, entities, transaction, commandTimeout, tableName, schemaName);
-
-
- ///
- /// Executes an insert query for the specified entity, returning the primary key.
- /// If the entity has a single key, just the value is returned.
- /// If the entity has a composite key, an IDictionary<string, object> is returned with the key values.
- /// The key value for the entity will also be updated if the KeyType is a Guid or Identity.
- ///
- public static dynamic Insert(this IDbConnection connection, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Insert(connection, null, entity, transaction, commandTimeout);
-
- public static dynamic Insert(this IDbConnection connection, string tableName, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Insert(connection, tableName, null, entity, transaction, commandTimeout);
-
- public static dynamic Insert(this IDbConnection connection, string tableName, string schemaName, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Instance.Insert(connection, entity, transaction, commandTimeout, tableName, schemaName);
-
- #endregion
-
- #region Update
- ///
- /// Executes an update query for the specified entity.
- ///
- public static bool Update(this IDbConnection connection, T entity, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => Update(connection, null, entity, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static bool Update(this IDbConnection connection, string tableName, T entity, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => Update(connection, tableName, null, entity, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static bool Update(this IDbConnection connection, string tableName, string schemaName, T entity, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => Instance.Update(connection, entity, null, transaction, commandTimeout, tableName, schemaName, ignoreAllKeyProperties);
-
-
- public static bool Update(this IDbConnection connection, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => Update(connection, null, entity, predicate, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static bool Update(this IDbConnection connection, string tableName, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => Update(connection, tableName, null, entity, predicate, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static bool Update(this IDbConnection connection, string tableName, string schemaName, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => Instance.Update(connection, entity, predicate, transaction, commandTimeout, tableName, schemaName, ignoreAllKeyProperties);
-
-
- public static async Task UpdateAsync(this IDbConnection connection, T entity, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => await UpdateAsync(connection, null, entity, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static async Task UpdateAsync(this IDbConnection connection, string tableName, T entity, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => await UpdateAsync(connection, tableName, null, entity, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static async Task UpdateAsync(this IDbConnection connection, string tableName, string schemaName, T entity, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => await Instance.UpdateAsync(connection, entity, null, transaction, commandTimeout, tableName, schemaName, ignoreAllKeyProperties);
-
- public static async Task UpdateAsync(this IDbConnection connection, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => await UpdateAsync(connection, null, entity, predicate, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static async Task UpdateAsync(this IDbConnection connection, string tableName, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => await UpdateAsync(connection, tableName, null, entity, predicate, transaction, commandTimeout, ignoreAllKeyProperties);
-
- public static async Task UpdateAsync(this IDbConnection connection, string tableName, string schemaName, T entity, object predicate, IDbTransaction transaction = null, int? commandTimeout = null, bool ignoreAllKeyProperties = false) where T : class
- => await Instance.UpdateAsync(connection, entity, predicate, transaction, commandTimeout, tableName, schemaName, ignoreAllKeyProperties);
-
-
-
- public static bool UpdateSet(this IDbConnection connection, object entity, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => UpdateSet(connection, null, entity, predicate, transaction, commandTimeout);
-
- public static bool UpdateSet(this IDbConnection connection, string tableName, object entity, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => UpdateSet(connection, tableName, null, entity, predicate, transaction, commandTimeout);
-
- public static bool UpdateSet(this IDbConnection connection, string tableName, string schemaName, object entity, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Instance.UpdateSet(connection, entity, predicate, transaction, commandTimeout, tableName, schemaName);
-
-
- public static async Task UpdateSetAsync(this IDbConnection connection, object entity, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await UpdateSetAsync(connection, null, entity, predicate, transaction, commandTimeout);
-
- public static async Task UpdateSetAsync(this IDbConnection connection, string tableName, object entity, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await UpdateSetAsync(connection, tableName, null, entity, predicate, transaction, commandTimeout);
-
- public static async Task UpdateSetAsync(this IDbConnection connection, string tableName, string schemaName, object entity, object predicate = null, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await Instance.UpdateSetAsync(connection, entity, predicate, transaction, commandTimeout, tableName, schemaName);
-
-
- #endregion
-
- #region Delete
- ///
- /// Executes a delete query for the specified entity.
- ///
- public static bool Delete(this IDbConnection connection, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Delete(connection, null, entity, transaction, commandTimeout);
-
- public static bool Delete(this IDbConnection connection, string tableName, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Delete(connection, tableName, null, entity, transaction, commandTimeout);
-
- public static bool Delete(this IDbConnection connection, string tableName, string schemaName, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Instance.Delete(connection, entity, transaction, commandTimeout, tableName, schemaName);
-
-
- public static async Task DeleteAsync(this IDbConnection connection, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await DeleteAsync(connection, null, entity, transaction, commandTimeout);
-
- public static async Task DeleteAsync(this IDbConnection connection, string tableName, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await DeleteAsync(connection, tableName, null, entity, transaction, commandTimeout);
-
- public static async Task DeleteAsync(this IDbConnection connection, string tableName, string schemaName, T entity, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await Instance.DeleteAsync(connection, entity, transaction, commandTimeout, tableName, schemaName);
-
-
- ///
- /// Executes a delete query using the specified predicate.
- ///
- public static bool Delete(this IDbConnection connection, object predicate, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Delete(connection, null, predicate, transaction, commandTimeout);
-
- public static bool Delete(this IDbConnection connection, string tableName, object predicate, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Delete(connection, tableName, null, predicate, transaction, commandTimeout);
-
- public static bool Delete(this IDbConnection connection, string tableName, string schemaName, object predicate, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => Instance.Delete(connection, predicate, transaction, commandTimeout, tableName, schemaName);
-
- public static async Task DeleteAsync(this IDbConnection connection, object predicate, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await DeleteAsync(connection, null, predicate, transaction, commandTimeout);
-
- public static async Task DeleteAsync(this IDbConnection connection, string tableName, object predicate, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await DeleteAsync(connection, tableName, null, predicate, transaction, commandTimeout);
-
- public static async Task DeleteAsync(this IDbConnection connection, string tableName, string schemaName, object predicate, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
- => await Instance.DeleteAsync(connection, predicate, transaction, commandTimeout, tableName, schemaName);
-
-
- #endregion
-
- #region GetList
- ///
- /// Executes a select query using the specified predicate, returning an IEnumerable data typed as per T.
- ///
- public static IEnumerable GetList(this IDbConnection connection, object predicate = null, IList sort = null, IDbTransaction transaction = null, int? commandTimeout = null, bool buffered = false) where T : class
- => GetList(connection, (string)null, null, predicate, sort, transaction, commandTimeout, buffered);
-
- public static IEnumerable GetList(this IDbConnection connection, string tableName, object predicate = null, IList sort = null, IDbTransaction transaction = null, int? commandTimeout = null, bool buffered = false) where T : class
- => GetList(connection, tableName, null, predicate, sort, transaction, commandTimeout, buffered);
-
- public static IEnumerable GetList