黄贺彬 6 rokov pred
rodič
commit
7fa386b6e9
100 zmenil súbory, kde vykonal 6664 pridanie a 586 odobranie
  1. 0 24
      .babelrc
  2. 0 14
      .editorconfig
  3. 0 23
      .eslintrc.js
  4. 0 35
      .gitattributes
  5. 0 53
      .template.config/template.json
  6. 0 34
      ClientApp/app.js
  7. 0 7
      ClientApp/boot-app.js
  8. 0 12
      ClientApp/boot-server.js
  9. 0 22
      ClientApp/components/app-root.vue
  10. 0 26
      ClientApp/components/nav-menu.vue
  11. 0 79
      ClientApp/css/site.css
  12. 0 18
      ClientApp/icons.js
  13. 0 29
      ClientApp/locale/index.js
  14. 0 3
      ClientApp/locale/lang/en-US.js
  15. 0 3
      ClientApp/locale/lang/zh-CN.js
  16. 0 3
      ClientApp/locale/lang/zh-TW.js
  17. 0 12
      ClientApp/router/index.js
  18. 0 9
      ClientApp/router/routes.js
  19. 0 3
      ClientApp/store/api.js
  20. 0 32
      ClientApp/store/index.js
  21. 0 16
      ClientApp/view/404.vue
  22. 0 33
      ClientApp/view/login.vue
  23. 0 16
      ClientApp/view/serverside/login.vue
  24. 0 17
      Controllers/HomeController.cs
  25. 0 46
      Controllers/ValuesController.cs
  26. 0 17
      Program.cs
  27. 22 0
      TEAMModelOS.Context.Attribute/AllowCors/AllowCorsAttribute.cs
  28. 11 0
      TEAMModelOS.Context.Attribute/TEAMModelOS.Context.Attribute.csproj
  29. 33 0
      TEAMModelOS.Context.Configuration/BaseConfigModel.cs
  30. 13 0
      TEAMModelOS.Context.Configuration/TEAMModelOS.Context.Configuration.csproj
  31. 31 0
      TEAMModelOS.Context.Constant/Common/Constants.cs
  32. 24 0
      TEAMModelOS.Context.Constant/Common/FileType.cs
  33. 44 0
      TEAMModelOS.Context.Constant/Common/FileTypeMap.cs
  34. 25 0
      TEAMModelOS.Context.Constant/Common/GetFileType.cs
  35. 59 0
      TEAMModelOS.Context.Constant/Common/ResponseCode.cs
  36. 7 0
      TEAMModelOS.Context.Constant/TEAMModelOS.Context.Constant.csproj
  37. 54 0
      TEAMModelOS.Context.Exception/BizException.cs
  38. 7 0
      TEAMModelOS.Context.Exception/TEAMModelOS.Context.Exception.csproj
  39. 148 0
      TEAMModelOS.Context.Filter/ExceptionInvoke/HttpGlobalExceptionInvoke.cs
  40. 17 0
      TEAMModelOS.Context.Filter/TEAMModelOS.Context.Filter.csproj
  41. 20 0
      TEAMModelOS.Extension.DataResult/JsonRpcRequest/AzureTokenJsonRPCRequest.cs
  42. 15 0
      TEAMModelOS.Extension.DataResult/JsonRpcRequest/BaseJosnRPCRequest.cs
  43. 11 0
      TEAMModelOS.Extension.DataResult/JsonRpcRequest/JosnRPCRequest.cs
  44. 15 0
      TEAMModelOS.Extension.DataResult/JsonRpcRequest/PaginationJosnRPCRequest.cs
  45. 14 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/BaseJosnRPCResponse.cs
  46. 16 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/DataJosnRPCResponse.cs
  47. 16 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/ErrorJosnRPCResponse.cs
  48. 13 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/ErrorModel.cs
  49. 13 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/JosnRPCResponse.cs
  50. 169 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/JsonRPCResponseBuilder.cs
  51. 16 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/JsonRPCResult.cs
  52. 17 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/PageJosnRPCResponse.cs
  53. 15 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/PageJsonRPCResult.cs
  54. 17 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/TokenJosnRPCResponse.cs
  55. 16 0
      TEAMModelOS.Extension.DataResult/JsonRpcResponse/TokenJsonRPCResult.cs
  56. 13 0
      TEAMModelOS.Extension.DataResult/PageToken/AzurePagination.cs
  57. 17 0
      TEAMModelOS.Extension.DataResult/PageToken/AzureTableToken.cs
  58. 31 0
      TEAMModelOS.Extension.DataResult/PageToken/Pagination.cs
  59. 12 0
      TEAMModelOS.Extension.DataResult/PageToken/PaginationData.cs
  60. 13 0
      TEAMModelOS.Extension.DataResult/RequestData/AzureTokenRequest.cs
  61. 12 0
      TEAMModelOS.Extension.DataResult/RequestData/BaseRequest.cs
  62. 10 0
      TEAMModelOS.Extension.DataResult/RequestData/PaginationRequest.cs
  63. 16 0
      TEAMModelOS.Extension.DataResult/ResponseData/BaseResponse.cs
  64. 14 0
      TEAMModelOS.Extension.DataResult/ResponseData/DataResponse.cs
  65. 15 0
      TEAMModelOS.Extension.DataResult/ResponseData/PageDatasResponse.cs
  66. 162 0
      TEAMModelOS.Extension.DataResult/ResponseData/ResponseBuilder.cs
  67. 16 0
      TEAMModelOS.Extension.DataResult/ResponseData/TimeStampResponse.cs
  68. 14 0
      TEAMModelOS.Extension.DataResult/ResponseData/TokenPageDatasResponse.cs
  69. 11 0
      TEAMModelOS.Extension.DataResult/TEAMModelOS.Extension.DataResult.csproj
  70. 7 0
      TEAMModelOS.Extension.JwtAuth/TEAMModelOS.Extension.JwtAuth.csproj
  71. 7 0
      TEAMModelOS.Extension.Language/TEAMModelOS.Extension.Language.csproj
  72. 7 0
      TEAMModelOS.Extension.MessagePush/TEAMModelOS.Extension.MessagePush.csproj
  73. 94 0
      TEAMModelOS.Helper.Common/DateTimeHelper/DateTimeHelper.cs
  74. 755 0
      TEAMModelOS.Helper.Common/FileHelper/FileHelper.cs
  75. 550 0
      TEAMModelOS.Helper.Common/FileHelper/FileHelperCore.cs
  76. 116 0
      TEAMModelOS.Helper.Common/JsonHelper/JsonSerialization.cs
  77. 74 0
      TEAMModelOS.Helper.Common/JsonHelper/MessagePackHelper.cs
  78. 35 0
      TEAMModelOS.Helper.Common/ReflectorExtensions/ReflectorExtensions.cs
  79. 77 0
      TEAMModelOS.Helper.Common/StringHelper/StringHelper.cs
  80. 14 0
      TEAMModelOS.Helper.Common/TEAMModelOS.Helper.Common.csproj
  81. 65 0
      TEAMModelOS.Helper.Common/ValidateHelper/ValidateHelper.cs
  82. 96 0
      TEAMModelOS.Helper.Network/HttpHelper/HttpContextHelper.cs
  83. 186 0
      TEAMModelOS.Helper.Network/HttpHelper/HttpHelper.cs
  84. 86 0
      TEAMModelOS.Helper.Network/NetworkHelper/NetworkHelper.cs
  85. 11 0
      TEAMModelOS.Helper.Network/TEAMModelOS.Helper.Network.csproj
  86. 175 0
      TEAMModelOS.Helper.Query/LinqHelper/DynamicLinq.cs
  87. 2336 0
      TEAMModelOS.Helper.Query/LinqHelper/DynamicQueryable.cs
  88. 13 0
      TEAMModelOS.Helper.Query/LinqHelper/Filter.cs
  89. 7 0
      TEAMModelOS.Helper.Query/TEAMModelOS.Helper.Query.csproj
  90. 218 0
      TEAMModelOS.Helper.Security/AESCrypt/AESCrypt.cs
  91. 29 0
      TEAMModelOS.Helper.Security/BCryptHelper/BCryptHelper.cs
  92. 69 0
      TEAMModelOS.Helper.Security/Base64Crypt/Base64Crypt.cs
  93. 133 0
      TEAMModelOS.Helper.Security/DesCrypt/DES3Crypt.cs
  94. 97 0
      TEAMModelOS.Helper.Security/DesCrypt/DESCrypt.cs
  95. 87 0
      TEAMModelOS.Helper.Security/Md5Hash/Md5Hash.cs
  96. 62 0
      TEAMModelOS.Helper.Security/RSACrypt/RSACrypt.cs
  97. 16 0
      TEAMModelOS.Helper.Security/TEAMModelOS.Helper.Security.csproj
  98. 1 0
      TEAMModelOS.Model.Analysis/README.md
  99. 7 0
      TEAMModelOS.Model.Analysis/TEAMModelOS.Model.Analysis.csproj
  100. 0 0
      TEAMModelOS.Model.Common/README.md

+ 0 - 24
.babelrc

@@ -1,24 +0,0 @@
-{
-  "presets": [
-    "@babel/preset-env"
-  ],
-  "plugins": [
-    "@babel/plugin-transform-runtime",
-    "@babel/plugin-transform-async-to-generator",
-    "@babel/plugin-syntax-dynamic-import",
-    "@babel/plugin-syntax-import-meta",
-    "@babel/plugin-proposal-class-properties",
-    "@babel/plugin-proposal-json-strings",
-    [
-      "@babel/plugin-proposal-decorators",
-      {
-        "legacy": true
-      }
-    ],
-    "@babel/plugin-proposal-function-sent",
-    "@babel/plugin-proposal-export-namespace-from",
-    "@babel/plugin-proposal-numeric-separator",
-    "@babel/plugin-proposal-throw-expressions"
-  ],
-  "comments": false
-}

+ 0 - 14
.editorconfig

@@ -1,14 +0,0 @@
-root = true
-
-[*]
-charset = utf-8
-indent_style = space
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.cs]
-indent_size = 4
-
-[*.{js,json,vue}]
-indent_size = 2

+ 0 - 23
.eslintrc.js

@@ -1,23 +0,0 @@
-module.exports = {
-  root: true,
-  parser: 'babel-eslint',
-  parserOptions: {
-    sourceType: 'module'
-  },
-  // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
-  extends: 'standard',
-  // We could also use the https://github.com/vuejs/eslint-plugin-vue
-  // required to lint *.vue files
-  plugins: [
-    'html'
-  ],
-  // add your custom rules here
-  'rules': {
-    // allow paren-less arrow functions
-    'arrow-parens': 0,
-    // allow async-await
-    'generator-star-spacing': 0,
-    // allow debugger during development
-    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
-  }
-}

+ 0 - 35
.gitattributes

@@ -1,35 +0,0 @@
-###############################################################################
-# Auto detect text files and perform LF normalization
-###############################################################################
-* text=auto
-
-###############################################################################
-# Force text and use native line endings for configuration and plain text
-# files, for easier editing on any platform.
-###############################################################################
-*.cs     text
-*.cshtml text
-*.js     text
-*.vue    text
-*.json   text
-*.css    text
-*.md     text
-*.config text
-
-###############################################################################
-# Set default behavior for command prompt diff.
-###############################################################################
-*.cs        diff=csharp
-
-###############################################################################
-# Set the merge driver for project and solution files
-#
-# Merging from the command prompt will add diff markers to the files if there
-# are conflicts (Merging from VS is not affected by the settings below, in VS
-# the diff markers are never inserted). Diff markers may cause the following 
-# file extensions to fail to load in VS. An alternative would be to treat
-# these files as binary and thus will always conflict and require user
-# intervention with every merge. To do so, just uncomment the entries below
-###############################################################################
-*.sln       merge=binary
-*.csproj    merge=binary

+ 0 - 53
.template.config/template.json

@@ -1,53 +0,0 @@
-{
-    "$schema": "http://json.schemastore.org/template",
-    "author": "Mark Pieszak, Mladen Mihajlovic",
-    "classifications": [ "Web", "MVC", "SPA" ],
-    "groupIdentity": "aspnetcore-vuejs",
-    "identity": "aspnetcore-vuejs.1.0",
-    "name": "ASP.NET Core with Vue.js 2",
-    "primaryOutputs": [
-        {
-          "path": "Vue2Spa.csproj"
-        }
-      ],
-    "shortName": "vuejs",
-    "tags": {
-        "language": "C#",
-        "type": "project"
-      },
-    "sourceName": "Vue2Spa",
-    "preferNameDirectory": true,
-    "sources": [
-        {
-          "source": "./",
-          "target": "./",
-          "exclude": [
-            ".template.config/**"
-          ]
-        }
-      ],
-    "guids": [
-        "B5FE715F-AB99-4FA6-AEC1-D3B644C76DF7"
-    ],
-    "symbols": {
-        "skipRestore": {
-            "type": "parameter",
-            "datatype": "bool",
-            "description": "If specified, skips the automatic restore of the project on create.",
-            "defaultValue": "false"
-          }
-    },
-    "postActions": [
-        {
-          "condition": "(!skipRestore)",
-          "description": "Restore NuGet packages required by this project.",
-          "manualInstructions": [
-            {
-              "text": "Run 'dotnet restore'"
-            }
-          ],
-          "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
-          "continueOnError": true
-        }
-      ]
-}

+ 0 - 34
ClientApp/app.js

@@ -1,34 +0,0 @@
-import Vue from 'vue'
-import axios from 'axios'
-import router from './router/index'
-import store from './store'
-import { sync } from 'vuex-router-sync'
-import App from 'components/app-root'
-import { FontAwesomeIcon } from './icons'
-import iView from 'iview';
-import 'iview/dist/styles/iview.css';
-import i18n from '@/locale'
-
-// Registration of global components
-Vue.component('icon', FontAwesomeIcon)
-
-Vue.prototype.$http = axios
-
-Vue.use(iView, {
-  i18n: (key, value) => i18n.t(key, value)
-})
-
-sync(store, router)
-
-const app = new Vue({
-  store,
-  router,
-  i18n,
-  ...App
-})
-
-export {
-  app,
-  router,
-  store
-}

+ 0 - 7
ClientApp/boot-app.js

@@ -1,7 +0,0 @@
-import './css/site.css'
-import 'core-js/es6/promise'
-import 'core-js/es6/array'
-
-import { app } from './app'
-
-app.$mount('#app')

+ 0 - 12
ClientApp/boot-server.js

@@ -1,12 +0,0 @@
-var prerendering = require('aspnet-prerendering')
-
-module.exports = prerendering.createServerRenderer(function (params) {
-  return new Promise(function (resolve, reject) {
-    var result = '<h1>Loading...</h1>' +
-            '<p>Current time in Node is: ' + new Date() + '</p>' +
-            '<p>Request path is: ' + params.location.path + '</p>' +
-            '<p>Absolute URL is: ' + params.absoluteUrl + '</p>'
-
-    resolve({ html: result })
-  })
-})

+ 0 - 22
ClientApp/components/app-root.vue

@@ -1,22 +0,0 @@
-<template>
-    <div id="app" class="container-fluid">
-        <router-view/>
-    </div>
-</template>
-
-<script>
-    import NavMenu from './nav-menu'
-
-    export default {
-      components: {
-        'nav-menu': NavMenu
-      },
-
-      data () {
-        return {}
-      }
-    }
-</script>
-
-<style>
-</style>

+ 0 - 26
ClientApp/components/nav-menu.vue

@@ -1,26 +0,0 @@
-<template>
-    <div class="main-nav">
-    </div>
-</template>
-
-<script>
-    import { routes } from '../router/routes'
-
-    export default {
-      data () {
-        return {
-          routes,
-          collapsed: true
-        }
-      },
-      methods: {
-        toggleCollapsed: function (event) {
-          this.collapsed = !this.collapsed
-        }
-      }
-    }
-</script>
-
-<style scoped>
-  
-</style>

+ 0 - 79
ClientApp/css/site.css

@@ -1,79 +0,0 @@
-/* This file should be reviewed. It's not optimal, but it works for now. */
-.navbar {
-    display: list-item;
-}
-
-/* Highlighting rules for nav menu items */
-.nav-item a.active,
-.nav-item a.active:hover,
-.nav-item a.active:focus {
-    background-color: #4189C7;
-    color: white;
-    text-decoration: underline;
-}
-
-.nav-item a,
-.nav-item a:hover,
-.nav-item a:focus {
-    color: white;
-}
-
-/* Keep the nav menu independent of scrolling and on top of other items */
-.main-nav {
-    position: fixed;
-    top: 0;
-    left: 0;
-    right: 0;
-    z-index: 1;
-}
-
-@media (max-width: 767px) {
-    /* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */
-    body {
-        padding-top: 50px;
-    }
-}
-
-@media (min-width: 768px) {
-    /* On small screens, convert the nav menu to a vertical sidebar */
-    .main-nav {
-        height: 100%;
-        width: calc(25% - 20px);
-    }    
-    .main-nav .navbar {
-        border-radius: 0px;
-        border-width: 0px;
-        height: 100%;
-    }
-    .navbar-expand-md .navbar-nav {
-        flex-direction: column;
-    }
-    .navbar-header {
-        float: none;
-    }
-    .navbar-collapse {
-        border-top: 1px solid #444;
-        padding: 0px;
-    }
-    .navbar-collapse ul {
-        float: none;
-    }
-    .nav-item {
-        float: none;
-        font-size: 15px;
-        margin: 6px;
-    }
-    .nav-item a {
-        padding: 10px 16px;
-        border-radius: 4px;
-        color: white;
-    }
-    
-    .navbar a {
-        /* If a menu item's text is too long, truncate it */
-        width: 95%; /* Bug to fix here. Width 100% overflow. */
-        white-space: nowrap;
-        overflow: hidden;
-        text-overflow: ellipsis;
-    }
-}

+ 0 - 18
ClientApp/icons.js

@@ -1,18 +0,0 @@
-import { library } from '@fortawesome/fontawesome-svg-core'
-import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
-
-library.add(
-  require('@fortawesome/free-solid-svg-icons').faEnvelope,
-  require('@fortawesome/free-solid-svg-icons').faGraduationCap,
-  require('@fortawesome/free-solid-svg-icons').faHome,
-  require('@fortawesome/free-solid-svg-icons').faList,
-  require('@fortawesome/free-solid-svg-icons').faSpinner,
-  // Brands
-  require('@fortawesome/free-brands-svg-icons').faFontAwesome,
-  require('@fortawesome/free-brands-svg-icons').faMicrosoft,
-  require('@fortawesome/free-brands-svg-icons').faVuejs
-)
-
-export {
-  FontAwesomeIcon
-}

+ 0 - 29
ClientApp/locale/index.js

@@ -1,29 +0,0 @@
-import Vue from 'vue'
-import VueI18n from 'vue-i18n'
-import customZhCn from './lang/zh-CN'
-import customZhTw from './lang/zh-TW'
-import customEnUs from './lang/en-US'
-
-Vue.use(VueI18n)
-
-// 自动根据浏览器系统语言设置语言
-const navLang = navigator.language
-const localLang = (navLang === 'zh-TW' || navLang === 'zh-CN' || navLang === 'en-US') ? navLang : false
-let lang = localLang || localStorage.getItem('local') || 'en-US'
-
-localStorage.setItem('local', lang);
-
-Vue.config.lang = lang
-
-Vue.locale = () => {}
-const messages = {
-  'zh-CN': customZhCn,
-  'zh-TW': customZhTw,
-  'en-US': customEnUs
-}
-const i18n = new VueI18n({
-  locale: lang,
-  messages
-})
-
-export default i18n

+ 0 - 3
ClientApp/locale/lang/en-US.js

@@ -1,3 +0,0 @@
-export default {
-  test: 'test',
-}

+ 0 - 3
ClientApp/locale/lang/zh-CN.js

@@ -1,3 +0,0 @@
-export default {
-  test: '测试',
-}

+ 0 - 3
ClientApp/locale/lang/zh-TW.js

@@ -1,3 +0,0 @@
-export default {
-  test: '測試',
-}

+ 0 - 12
ClientApp/router/index.js

@@ -1,12 +0,0 @@
-import Vue from 'vue'
-import VueRouter from 'vue-router'
-import { routes } from './routes'
-
-Vue.use(VueRouter)
-
-let router = new VueRouter({
-  mode: 'history',
-  routes
-})
-
-export default router

+ 0 - 9
ClientApp/router/routes.js

@@ -1,9 +0,0 @@
-import Login from '@/view/login'
-import ServerSideLogin from '@/view/serverside/login'
-import HTTP404 from '@/view/404'
-
-export const routes = [
-  { name: 'login', path: '/', component: Login, display: 'Home', icon: 'home' },
-  { name: 'ServerSideLogin', path: '/serverside/login', component: ServerSideLogin, display: 'Home', icon: 'home' },
-  { name: 'HTTP404', path: '/*', component: HTTP404, display: 'Home', icon: 'home' },
-]

+ 0 - 3
ClientApp/store/api.js

@@ -1,3 +0,0 @@
-export function test () {
-
-}

+ 0 - 32
ClientApp/store/index.js

@@ -1,32 +0,0 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-
-Vue.use(Vuex)
-
-// TYPES
-const MAIN_SET_COUNTER = 'MAIN_SET_COUNTER'
-
-// STATE
-const state = {
-  counter: 1
-}
-
-// MUTATIONS
-const mutations = {
-  [MAIN_SET_COUNTER] (state, obj) {
-    state.counter = obj.counter
-  }
-}
-
-// ACTIONS
-const actions = ({
-  setCounter ({ commit }, obj) {
-    commit(MAIN_SET_COUNTER, obj)
-  }
-})
-
-export default new Vuex.Store({
-  state,
-  mutations,
-  actions
-})

+ 0 - 16
ClientApp/view/404.vue

@@ -1,16 +0,0 @@
-<template>
-    <div>
-       <h1>404</h1>
-    </div>
-</template>
-
-<script>
-export default {
-  data () {
-    return {}
-  }
-}
-</script>
-
-<style>
-</style>

+ 0 - 33
ClientApp/view/login.vue

@@ -1,33 +0,0 @@
-<template>
-    <div>
-       <h1>LOGIN</h1>
-       <h2>{{ $t('test')}}</h2>
-        <Card>
-          <p slot="title">RESTful測試</p>
-          <Button @click="ajax_TEST">測試按鈕1</Button>
-          <pre>{{ testStr }}</pre>
-        </Card>
-    </div>
-</template>
-
-<script>
-export default {
-  data () {
-    return {
-      testStr: 'RESTful',
-      testStr2: 'Json RPC',
-    }
-  },
-  methods:{
-    ajax_TEST: function(){
-      this.$http.get('/api/values')
-      .then(response => {
-        this.testStr = response.data
-      }).catch((error) => console.log(error))
-    }
-  }
-}
-</script>
-
-<style>
-</style>

+ 0 - 16
ClientApp/view/serverside/login.vue

@@ -1,16 +0,0 @@
-<template>
-    <div>
-       <h1>SERVER SIDE LOGIN</h1>
-    </div>
-</template>
-
-<script>
-export default {
-  data () {
-    return {}
-  }
-}
-</script>
-
-<style>
-</style>

+ 0 - 17
Controllers/HomeController.cs

@@ -1,17 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-
-namespace TEAMModelOS.Controllers
-{
-    public class HomeController : Controller
-    {
-        public IActionResult Index()
-        {
-            return View();
-        }
-
-        public IActionResult Error()
-        {
-            return View();
-        }
-    }
-}

+ 0 - 46
Controllers/ValuesController.cs

@@ -1,46 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-
-namespace TEAMModelOS.Controllers
-{
-    [Route("api/[controller]")]
-    [ApiController]
-    public class ValuesController : ControllerBase
-    {
-        // GET api/values
-        [HttpGet]
-        public ActionResult<IEnumerable<string>> Get()
-        {
-            return new string[] { "value1", "value2" };
-        }
-
-        // GET api/values/5
-        [HttpGet("{id}")]
-        public ActionResult<string> Get(int id)
-        {
-            return null;
-        }
-
-        // POST api/values
-        [HttpPost]
-        public void Post([FromBody] string value)
-        {
-        }
-
-        // PUT api/values/5
-        [HttpPut("{id}")]
-        public void Put(int id, [FromBody] string value)
-        {
-        }
-
-        // DELETE api/values/5
-        [HttpDelete("{id}")]
-        public void Delete(int id)
-        {
-        }
-    }
-}

+ 0 - 17
Program.cs

@@ -1,17 +0,0 @@
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
-
-namespace TEAMModelOS
-{
-    public class Program
-    {
-        public static void Main(string[] args)
-        {
-            CreateWebHostBuilder(args).Build().Run();
-        }
-
-        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
-           WebHost.CreateDefaultBuilder(args)
-               .UseStartup<Startup>();
-    }
-}

+ 22 - 0
TEAMModelOS.Context.Attribute/AllowCors/AllowCorsAttribute.cs

@@ -0,0 +1,22 @@
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace TEAMModelOS.Context.Attribute.AllowCors
+{
+    /// <summary>
+    /// 跨域处理
+    /// </summary>
+    public class AllowCorsAttribute : ActionFilterAttribute
+    {
+        public override void OnActionExecuting(ActionExecutingContext filterContext)
+        {
+            var context = filterContext.HttpContext;
+            //context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
+            context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS, POST, PUT");
+            context.Response.Headers.Add("Access-Control-Allow-Headers", "Access-Control-Allow-Headers," +
+                                         " Origin,Accept, X-Requested-With, Content-Type, " +
+                                         "Access-Control-Request-Method, Access-Control-Request-Headers," +
+                                         "Content-Type,Accept,access_token,token,Authorization");
+            base.OnActionExecuting(filterContext);
+        }
+    }
+}

+ 11 - 0
TEAMModelOS.Context.Attribute/TEAMModelOS.Context.Attribute.csproj

@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0" />
+  </ItemGroup>
+
+</Project>

+ 33 - 0
TEAMModelOS.Context.Configuration/BaseConfigModel.cs

@@ -0,0 +1,33 @@
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+
+namespace TEAMModelOS.Context.Configuration
+{
+    public class BaseConfigModel
+    {
+        public static IConfiguration Configuration { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+
+        public static string ContentRootPath { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+
+        public static string WebRootPath { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="config"></param>
+        /// <param name="contentRootPath"></param>
+        /// <param name="webRootPath"></param>
+        public static void SetBaseConfig(IConfiguration config, string contentRootPath, string webRootPath)
+        {
+            Configuration = config;
+            ContentRootPath = contentRootPath;
+            WebRootPath = webRootPath;
+        }
+    }
+}

+ 13 - 0
TEAMModelOS.Context.Configuration/TEAMModelOS.Context.Configuration.csproj

@@ -0,0 +1,13 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
+    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
+    <PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
+  </ItemGroup>
+
+</Project>

+ 31 - 0
TEAMModelOS.Context.Constant/Common/Constants.cs

@@ -0,0 +1,31 @@
+
+namespace TEAMModelOS.Context.Constant.Common
+{
+    public static class Constants
+    {
+        /// <summary>
+        /// access_token
+        /// </summary>
+		public static readonly string ACCESS_TOKEN = "access_token";
+        /// <summary>
+        /// 引用页
+        /// </summary>
+		public static readonly string REFERER = "referer";
+        /// <summary>
+        /// token 请求头
+        /// </summary>
+		public static readonly string AUTHORIZATION = "Authorization";
+        /// <summary>
+        /// josn格式
+        /// </summary>
+		public static readonly string CONTENT_TYPE_JSON = "application/json";
+        /// <summary>
+        /// 苏格拉底作品类型--团队组
+        /// </summary>
+		public static readonly string SIGNUPTYPEGRP = "2018TMCNTSGRP";
+        /// <summary>
+        /// 苏格拉底作品类型--个人组
+        /// </summary>
+		public static readonly string SIGNUPTYPEINT = "2018TMCNTSIND";
+    }
+}

+ 24 - 0
TEAMModelOS.Context.Constant/Common/FileType.cs

@@ -0,0 +1,24 @@
+namespace TEAMModelOS.Context.Constant.Common
+{
+	public class FileType
+	{
+		public string Id { get; set;}
+		public string Extention { get; set; }
+		public string Type { get; set; }
+
+		public FileType(string id, string extention, string type)
+		{
+			Id = id;
+			Extention = extention;
+			Type = type;
+		}
+		public static string GetExtention(string fileName) {
+			if (string.IsNullOrEmpty(fileName)) {
+				return "";
+			} else {
+				return fileName.Substring(fileName.LastIndexOf(".") + 1);
+			}
+			
+		}
+	}
+}

+ 44 - 0
TEAMModelOS.Context.Constant/Common/FileTypeMap.cs

@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+
+
+namespace TEAMModelOS.Context.Constant.Common
+{
+	public class FileTypeMap
+	{
+		private Dictionary<string, FileType> FileTpyeMap { get; set; }
+
+		public FileTypeMap FileTypes(FileType fileType) {
+			if (this.FileTpyeMap == null)
+			{
+				FileTpyeMap = new Dictionary<string, FileType>();
+				//fileTpyeMap.Add(fileType.Type, fileType);
+			}
+			if(!FileTpyeMap.ContainsKey(fileType.Extention)) {
+				FileTpyeMap.Add(fileType.Extention, fileType);
+			}
+			return this;
+		}
+		public Dictionary<string, FileType> GetFileTypes() {
+			FileTypes(new FileType("1", "jpg", "img")).
+			FileTypes(new FileType("2", "png", "img")).
+			FileTypes(new FileType("3", "bmp", "img")).
+			FileTypes(new FileType("4", "jpeg", "img")).
+			FileTypes(new FileType("5", "gif", "img")).
+			FileTypes(new FileType("6", "mp4", "video")).
+			FileTypes(new FileType("7", "avi", "video")).
+			FileTypes(new FileType("8", "mpeg", "video")).
+			FileTypes(new FileType("9", "mov", "video")).
+			FileTypes(new FileType("10", "wmv", "video")).
+			FileTypes(new FileType("11", "doc", "file")).
+			FileTypes(new FileType("12", "docx", "file")).
+			FileTypes(new FileType("13", "ppt", "file")).
+			FileTypes(new FileType("14", "pptx", "file")).
+			FileTypes(new FileType("15", "xls", "file")).
+			FileTypes(new FileType("16", "xlsx", "file")).
+			FileTypes(new FileType("17", "zip", "file")).
+			FileTypes(new FileType("18", "rar", "file")).
+			FileTypes(new FileType("19", "pdf", "file"));
+			return FileTpyeMap;
+		}
+	}
+}

+ 25 - 0
TEAMModelOS.Context.Constant/Common/GetFileType.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Context.Constant.Common
+{
+	public class GetFileType
+	{
+		//private 
+
+		public GetFileType() { 
+		
+		}
+
+		public string GetExtension(string fileName) {
+			return fileName.Substring(fileName.LastIndexOf(".") + 1, (fileName.Length - fileName.LastIndexOf(".") - 1)); //扩展名
+		}
+
+		public string GetType(string fileName) {
+			string extension = GetExtension(fileName);
+
+			return null;
+		}
+	}
+}

+ 59 - 0
TEAMModelOS.Context.Constant/Common/ResponseCode.cs

@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Context.Constant.Common
+{
+
+    /// <summary>
+    /// 响应编码
+    /// </summary>
+    public static class ResponseCode
+    {
+        /// <summary>
+        /// 代表HTTP正常请求
+        /// </summary>
+        public readonly static int HTTP_SUCCESS = 200;
+        /// <summary>
+        /// 一般常用代表成功
+        /// </summary>
+        public readonly static int SUCCESS = 0;
+        /// <summary>
+        /// 一般常用代表失败
+        /// </summary>
+        public readonly static int FAILED = 1;
+        /// <summary>
+        /// 数据为空或null
+        /// </summary>
+        public readonly static int DATA_EMPTY_NULL = 2;
+        /// <summary>
+        /// 参数异常
+        /// </summary>
+        public readonly static int PARAMS_ERROR = 3;
+        /// <summary>
+        /// 服务端异常
+        /// </summary>
+        public readonly static int SERVER_ERROR = 500;
+        /// <summary>
+        /// 未知异常
+        /// </summary>
+        public readonly static int UNDEFINED = 9;
+        /// <summary>
+        /// 资源未找到
+        /// </summary>
+        public readonly static int NOT_FOUND = 404;
+        /// <summary>
+        /// 未授权
+        /// </summary>
+        public readonly static int UNAUTH = 401;
+        /// <summary>
+        /// 网关路由异常
+        /// </summary>
+        public readonly static int GATEWAY_ERROR = 504;
+        /// <summary>
+        /// 响应超时
+        /// </summary>
+        public readonly static int TIMEOUT_ERROR = 503;
+        
+    }
+}

+ 7 - 0
TEAMModelOS.Context.Constant/TEAMModelOS.Context.Constant.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 54 - 0
TEAMModelOS.Context.Exception/BizException.cs

@@ -0,0 +1,54 @@
+using System;
+
+namespace TEAMModelOS.Context.Exception
+{
+    public class BizException : System.Exception
+    {
+        public string message { get; set; } = "error";
+        public int code { get; set; } = 1;
+        public string devMessage { get; set; }
+        public BizException(int code, String message, string stackTrace) : base(message)
+        {
+            if (string.IsNullOrEmpty(stackTrace))
+            {
+                this.devMessage = this.StackTrace;
+            }
+            else
+            {
+                this.devMessage = stackTrace;
+            }
+            this.message = message;
+            this.code = code;
+        }
+        public BizException(int code, String message) : base(message)
+        {
+            this.devMessage = this.StackTrace;
+            this.message = message;
+            this.code = code;
+        }
+        //
+        // 摘要:
+        //     Initializes a new instance of the System.Exception class.
+        public BizException() : base()
+        {
+            this.devMessage = this.StackTrace;
+            this.message = "error";
+            this.code = 1;
+        }
+
+        //
+        // 摘要:
+        //     Initializes a new instance of the System.Exception class with a specified error
+        //     message.
+        //
+        // 参数:
+        //   message:
+        //     The message that describes the error.
+        public BizException(string message) : base(message)
+        {
+            this.message = message;
+            this.devMessage = this.StackTrace;
+            this.code = 1;
+        }
+    }
+}

+ 7 - 0
TEAMModelOS.Context.Exception/TEAMModelOS.Context.Exception.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 148 - 0
TEAMModelOS.Context.Filter/ExceptionInvoke/HttpGlobalExceptionInvoke.cs

@@ -0,0 +1,148 @@
+using MessagePack;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Threading.Tasks;
+using TEAMModelOS.Context.Constant.Common;
+using TEAMModelOS.Context.Exception;
+using TEAMModelOS.Helper.Common.JsonHelper;
+
+namespace TEAMModelOS.Context.Filter.ExceptionInvoke
+{
+    public class HttpGlobalExceptionInvoke
+    {
+        private readonly RequestDelegate _next;
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="next"></param>
+        public HttpGlobalExceptionInvoke(RequestDelegate next)
+        {
+            _next = next;
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        public async Task Invoke(HttpContext context)
+        {
+
+            System.Exception exs = null;
+            bool isCatched = false;
+            try
+            {
+                await _next(context);
+            }
+            catch (System.Exception ex) //发生异常
+            {
+                exs = ex;
+                //自定义业务异常
+                if (ex is BizException)
+                {
+                    context.Response.StatusCode = ((BizException)ex).code;
+                }
+                //未知异常
+                else
+                {
+                    context.Response.StatusCode = 500;
+                    //LogHelper.SetLog(LogLevel.Error, ex);
+                }
+                await HandleExceptionAsync(context, context.Response.StatusCode, ex.Message, ex.StackTrace);
+                isCatched = true;
+            }
+            finally
+            {
+                if (!isCatched && context.Response.StatusCode != 200)//未捕捉过并且状态码不为200
+                {
+                    string msg = "";
+                    switch (context.Response.StatusCode)
+                    {
+                        case 401:
+                            msg = "Unauthorized";
+                            break;
+                        case 404:
+                            msg = "Service Not Found";
+                            break;
+                        case 502:
+                            msg = "Request Erro";
+                            break;
+                        case 500:
+                            msg = exs.Message;
+                            break;
+                        default:
+                            msg = "Unknown Error";
+                            break;
+                    }
+                    await HandleExceptionAsync(context, context.Response.StatusCode, msg, exs == null ? "" : exs.StackTrace);
+                }
+            }
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="context"></param>
+        /// <param name="statusCode"></param>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        private static async Task HandleExceptionAsync(HttpContext context, int statusCode, string msg, string devmsg)
+        {
+            var data = new ErrorResponse<string>(statusCode, msg, devmsg);
+            context.Response.ContentType = Constants.CONTENT_TYPE_JSON;
+            await context.Response.WriteAsync(MessagePackHelper.ObjectToJson(data));
+        }
+        /// <summary>
+        /// 异常信息封装
+        /// </summary>
+        /// 
+        [MessagePackObject(keyAsPropertyName: true)]
+        public class ErrorResponse<T>
+        {
+            public ErrorResponse()
+            {
+                error = new ErrorModel<T>();
+            }
+            public ErrorResponse(string message)
+            {
+                error = new ErrorModel<T>
+                {
+                    message = message,
+                    devmsg = message
+                };
+            }
+            public ErrorResponse(int code, string message)
+            {
+                error = new ErrorModel<T>
+                {
+                    message = message,
+                    devmsg = message,
+                    code = code
+                };
+
+            }
+            public ErrorResponse(int code, string message, string devMessage)
+            {
+                error = new ErrorModel<T>
+                {
+                    message = message,
+                    devmsg = message,
+                    code = code
+                };
+                error.devmsg = devMessage;
+            }
+
+            public string jsonrpc { get; set; } = "2.0";
+            public double id { get; set; } = 1;
+            private object result { get; set; } = null;
+            public ErrorModel<T> error { get; set; } = null;
+        }
+    }
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ErrorModel<E>
+    {
+        public long responseTime = DateTime.Now.Ticks;
+        public float code { get; set; } = 1;
+        public string message { get; set; }
+        public string devmsg { get; set; }
+        public E data { get; set; }
+    }
+}

+ 17 - 0
TEAMModelOS.Context.Filter/TEAMModelOS.Context.Filter.csproj

@@ -0,0 +1,17 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\TEAMModelOS.Context.Constant\TEAMModelOS.Context.Constant.csproj" />
+    <ProjectReference Include="..\TEAMModelOS.Context.Exception\TEAMModelOS.Context.Exception.csproj" />
+    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
+  </ItemGroup>
+
+</Project>

+ 20 - 0
TEAMModelOS.Extension.DataResult/JsonRpcRequest/AzureTokenJsonRPCRequest.cs

@@ -0,0 +1,20 @@
+using TEAMModelOS.Extension.DataResult.RequestData;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcRequest
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public class AzureTokenJsonRPCRequest<T> : BaseJosnRPCRequest
+    {
+
+        public AzureTokenJsonRPCRequest (){
+            @params = new AzureTokenRequest<T>();
+        }
+        public AzureTokenRequest<T> @params { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.Extension.DataResult/JsonRpcRequest/BaseJosnRPCRequest.cs

@@ -0,0 +1,15 @@
+using MessagePack;
+using System;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcRequest
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public abstract class BaseJosnRPCRequest
+    {
+        public long requestTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public string jsonrpc { get; set; } = "2.0";
+        public string method { get; set; }
+        public int id { get; set; } = 1;
+        public int timeOffset { get; set; }
+    }
+}

+ 11 - 0
TEAMModelOS.Extension.DataResult/JsonRpcRequest/JosnRPCRequest.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcRequest
+{
+    public class JosnRPCRequest<T>:BaseJosnRPCRequest
+    {
+        public T @params { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.Extension.DataResult/JsonRpcRequest/PaginationJosnRPCRequest.cs

@@ -0,0 +1,15 @@
+
+
+using TEAMModelOS.Extension.DataResult.RequestData;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcRequest
+{
+    public  class PaginationJosnRPCRequest<T> : BaseJosnRPCRequest
+    {
+        public PaginationJosnRPCRequest()
+        {
+            @params = new PaginationRequest<T>();
+        }
+        public PaginationRequest<T> @params { get; set; }
+    }
+}

+ 14 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/BaseJosnRPCResponse.cs

@@ -0,0 +1,14 @@
+using MessagePack;
+using Microsoft.VisualBasic;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class BaseJosnRPCResponse 
+    {
+        public string jsonrpc { get; set; } = "2.0";
+        public double id { get; set; } = 1;
+        private object result { get; set; }
+        public object error { get; set; } = null;
+    }
+}

+ 16 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/DataJosnRPCResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class DataJosnRPCResponse<T> : BaseJosnRPCResponse
+    {
+		public DataJosnRPCResponse() { 
+		  result=  new JsonRPCResult<T>();
+		}
+		public   JsonRPCResult<T> result { get; set; } 
+    }
+}

+ 16 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/ErrorJosnRPCResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ErrorJosnRPCResponse<E> : BaseJosnRPCResponse
+    {
+        public ErrorJosnRPCResponse() {
+            error = new ErrorModel<E>();
+        }
+        public new ErrorModel<E> error { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/ErrorModel.cs

@@ -0,0 +1,13 @@
+using MessagePack;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ErrorModel<E>
+    {
+        public float code { get; set; }
+        public string message { get; set; }
+        public string devmsg { get; set; }
+        public E data { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/JosnRPCResponse.cs

@@ -0,0 +1,13 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class JosnRPCResponse<T>:BaseJosnRPCResponse
+    {
+        public  T result { get; set; }
+    }
+}

+ 169 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/JsonRPCResponseBuilder.cs

@@ -0,0 +1,169 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public  class JsonRPCResponseBuilder
+    {
+        private string message="Success";
+        private string devmsg = "Error";
+        private int code = 0;
+        private object data;
+        private long total;
+        private int currPage;
+        private int pageSize;
+        private int totalPage;
+        private Dictionary<string, object> extend;
+        private Pagination page;
+        private AzureTableToken token;
+        private object error=null;
+        
+        public JsonRPCResponseBuilder()
+        {
+        }
+        public JsonRPCResponseBuilder Success()
+        {
+            error = null;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder Success(String message)
+        {
+            this.message = message;
+            return this;
+        }
+        public static JsonRPCResponseBuilder custom()
+        {
+            return new JsonRPCResponseBuilder();
+        }
+
+        public JsonRPCResponseBuilder Data(object data)
+        {
+            this.data = data;
+            return this;
+        }
+		public JsonRPCResponseBuilder Error(object error, string message)
+		{
+			this.code = 1;
+			this.message = message;
+			this.error = error;
+			return this;
+		}
+		public JsonRPCResponseBuilder Error(object error, int code,string message)
+		{
+			this.code = code;
+			this.message = message;
+			this.error = error;
+			return this;
+		}
+		public JsonRPCResponseBuilder Error(object error,int code)
+		{
+			this.code = code;
+			this.message = "Error";
+			this.error = error;
+			return this;
+		}
+		public JsonRPCResponseBuilder Error(object error)
+        {
+			this.code = 1;
+			this.message = "Error";
+            this.error = error;
+            return this;
+        }
+        public JsonRPCResponseBuilder Extend(Dictionary<String, object> extend)
+        {
+            this.extend = extend;
+            return this;
+        }
+        public JsonRPCResponseBuilder Token(AzureTableToken token)
+        {
+            this.token = token;
+            return this;
+        }
+        public JsonRPCResponseBuilder Page(Pagination page)
+        {
+            this.pageSize = page.pageSize;
+            this.currPage = page.currPage;
+            this.total = page.total;
+            this.page = page;
+            this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            return this;
+        }
+        public JsonRPCResponseBuilder totalCount(int totalCount)
+        {
+            this.total = totalCount;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder CurrPage(int currPage)
+        {
+            this.currPage = currPage;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder PageSize(int pageSize)
+        {
+            this.pageSize = pageSize;
+            return this;
+        }
+
+        public JsonRPCResponseBuilder TotalPage(int totalPage)
+        {
+            this.totalPage = totalPage;
+            return this;
+        }
+        public BaseJosnRPCResponse build()
+        {
+            object baseResponse= null;
+
+            if (error != null) {
+                ErrorJosnRPCResponse<object> errorJosnRPCResponse = new ErrorJosnRPCResponse<object>();
+                errorJosnRPCResponse.error.code = code;
+                errorJosnRPCResponse.error.message = message;
+                errorJosnRPCResponse.error.data = error;
+                errorJosnRPCResponse.error.devmsg = devmsg;
+                baseResponse = errorJosnRPCResponse;
+                return (BaseJosnRPCResponse)baseResponse;
+            }
+            if (this.total > 0 && this.pageSize > 0)
+            {
+                this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            }
+            if (null != this.data && this.token != null)
+            {
+                TokenJosnRPCResponse<object> tokenJosnRPCResponse = new TokenJosnRPCResponse<object>();
+                tokenJosnRPCResponse.result.data = this.data;
+                tokenJosnRPCResponse.result.extend = this.extend;
+                tokenJosnRPCResponse.result.azureToken = this.token;
+                tokenJosnRPCResponse.result.message = message;
+                baseResponse = tokenJosnRPCResponse;
+            }
+            else if (null != this.data && this.total > 0 && this.currPage > 0 && this.pageSize > 0 && this.totalPage > 0)
+            {
+                PageJosnRPCResponse<object> pageDatasResponse = new PageJosnRPCResponse<object>();
+                pageDatasResponse.result.data = this.data;
+                pageDatasResponse.result.page = new Pagination(this.total, this.currPage, this.pageSize, this.totalPage);
+                pageDatasResponse.result.extend = this.extend;
+                pageDatasResponse.result.message = message;
+                baseResponse = pageDatasResponse;
+            }
+            else if (this.data != null)
+            {
+                DataJosnRPCResponse<object> datasResponse = new DataJosnRPCResponse<object>();
+                datasResponse.result.data = this.data;
+                datasResponse.result.extend = this.extend;
+                datasResponse.result.message = message;
+                baseResponse = datasResponse;
+            }
+            else
+            {
+                baseResponse = new BaseJosnRPCResponse();
+            }
+            return (BaseJosnRPCResponse)baseResponse;
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/JsonRPCResult.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class JsonRPCResult<T>
+    {
+        public Dictionary<string, object> extend { get; set; } = null;
+        public long responseTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public T data { get; set; }
+        public string message { get; set; } = "";
+    }
+}

+ 17 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/PageJosnRPCResponse.cs

@@ -0,0 +1,17 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class PageJosnRPCResponse<T> : BaseJosnRPCResponse
+    {
+		public PageJosnRPCResponse()
+		{
+			result = new PageJsonRPCResult<T>();
+		}
+		public   PageJsonRPCResult<T> result { get; set; }
+    }
+}

+ 15 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/PageJsonRPCResult.cs

@@ -0,0 +1,15 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using MessagePack;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class PageJsonRPCResult<T> : JsonRPCResult<T>
+    {
+        public Pagination page { get; set; }
+
+        public PageJsonRPCResult()
+        {
+        }
+    }
+}

+ 17 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/TokenJosnRPCResponse.cs

@@ -0,0 +1,17 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TokenJosnRPCResponse<T>: BaseJosnRPCResponse
+    {
+		public TokenJosnRPCResponse()
+		{
+			result = new TokenJsonRPCResult<T>();
+		}
+		public  TokenJsonRPCResult<T> result { get; set; }
+    }
+}

+ 16 - 0
TEAMModelOS.Extension.DataResult/JsonRpcResponse/TokenJsonRPCResult.cs

@@ -0,0 +1,16 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.JsonRpcResponse
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TokenJsonRPCResult<T> : JsonRPCResult<T>
+    {
+       
+        public AzureTableToken azureToken { get; set; }
+        public TokenJsonRPCResult() { }
+    }
+}

+ 13 - 0
TEAMModelOS.Extension.DataResult/PageToken/AzurePagination.cs

@@ -0,0 +1,13 @@
+using MessagePack;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.Extension.DataResult.PageToken
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class AzurePagination<T>
+    {
+        public AzurePagination(){}
+        public List<T> data { get; set; }
+        public AzureTableToken token { get; set; }
+    }
+}

+ 17 - 0
TEAMModelOS.Extension.DataResult/PageToken/AzureTableToken.cs

@@ -0,0 +1,17 @@
+using MessagePack;
+using System.ComponentModel.DataAnnotations;
+
+namespace TEAMModelOS.Extension.DataResult.PageToken
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class AzureTableToken
+    {
+        //[Required]
+        public string NextPartitionKey { get; set; }
+        //[Required]
+        public string NextRowKey { get; set; }
+        public string NextTableName { get; set; }
+        //[Required]
+        public int? TargetLocation { get; set; }
+    }
+}

+ 31 - 0
TEAMModelOS.Extension.DataResult/PageToken/Pagination.cs

@@ -0,0 +1,31 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.Extension.DataResult.PageToken
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class Pagination
+    {
+        public long total { get; set; }
+        public int currPage { get; set; }
+        public int pageSize { get; set; } 
+        public int totalPage { get; set; }
+      
+        public Pagination() { }
+        public Pagination(long total, int currPage, int pageSize)
+        {
+            this.total = total;
+            this.currPage = currPage;
+            this.pageSize = pageSize;
+            this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+        }
+        public Pagination(long total, int currPage, int pageSize, int totalPage)
+        {
+            this.total = total;
+            this.currPage = currPage;
+            this.pageSize = pageSize;
+            this.totalPage = totalPage;
+        }
+    }
+}

+ 12 - 0
TEAMModelOS.Extension.DataResult/PageToken/PaginationData.cs

@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace TEAMModelOS.Extension.DataResult.PageToken
+{
+    public class PaginationData<T>:Pagination
+    {
+        public PaginationData(int currPage, int pageSize, int total) : base(currPage, pageSize, total)
+        {
+        }
+        public List<T> data { get; set; }
+    }
+}

+ 13 - 0
TEAMModelOS.Extension.DataResult/RequestData/AzureTokenRequest.cs

@@ -0,0 +1,13 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Extension.DataResult.RequestData
+{
+   public class AzureTokenRequest<T> :BaseRequest
+   {
+        public T data { get; set; }
+        public AzureTableToken azureToken { get; set; }
+   }
+}

+ 12 - 0
TEAMModelOS.Extension.DataResult/RequestData/BaseRequest.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.Extension.DataResult.RequestData
+{
+    public class BaseRequest
+    {
+        public long requestTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public string method { get; set; }
+        public string repeatToken { get; set; }
+    }
+}

+ 10 - 0
TEAMModelOS.Extension.DataResult/RequestData/PaginationRequest.cs

@@ -0,0 +1,10 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+
+namespace TEAMModelOS.Extension.DataResult.RequestData
+{
+    public class PaginationRequest<T> : BaseRequest
+    {
+        public T data { get; set; }
+        public Pagination  page{ get; set; }
+    }
+}

+ 16 - 0
TEAMModelOS.Extension.DataResult/ResponseData/BaseResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System.Collections.Generic;
+
+namespace TEAMModelOS.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class BaseResponse : TimeStampResponse
+    {
+        public Dictionary<string, object> extend { get; set; }
+        public string message { get; set; } = "success";
+        public int code { get; set; }
+        public BaseResponse()
+        {
+        }
+    }
+}

+ 14 - 0
TEAMModelOS.Extension.DataResult/ResponseData/DataResponse.cs

@@ -0,0 +1,14 @@
+using MessagePack;
+
+namespace TEAMModelOS.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class DataResponse<T> : BaseResponse
+    {
+        public T data { get; set; }
+
+        public DataResponse()
+        {
+        }
+    }
+}

+ 15 - 0
TEAMModelOS.Extension.DataResult/ResponseData/PageDatasResponse.cs

@@ -0,0 +1,15 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using MessagePack;
+
+namespace TEAMModelOS.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class PageDatasResponse<T> : DataResponse<T>
+    {
+        public Pagination page { get; set; }
+
+        public PageDatasResponse()
+        {
+        }
+    }
+}

+ 162 - 0
TEAMModelOS.Extension.DataResult/ResponseData/ResponseBuilder.cs

@@ -0,0 +1,162 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using MessagePack;
+using System;
+using System.Collections.Generic;
+
+
+namespace TEAMModelOS.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class ResponseBuilder
+    {
+        private string message = "success";
+        private object data;
+        private int code = 0;
+       // private IList<object> datas;
+        private long total;
+        private int currPage;
+        private int pageSize;
+        private int totalPage;
+        private Dictionary<string, object> extend;
+        private Pagination page;
+        private AzureTableToken  token;
+        public ResponseBuilder()
+        {
+        }
+
+        public static ResponseBuilder custom()
+        {
+            return new ResponseBuilder();
+        }
+
+        public BaseResponse build()
+        {
+            if (this.total > 0 && this.pageSize > 0 )
+            {
+                this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            }
+            object baseResponse;
+           
+             if (null != this.data && this.token!=null)
+            {
+                TokenPageDatasResponse<object> pageDatasResponse = new TokenPageDatasResponse<object>();
+                pageDatasResponse.code= this.code;
+                pageDatasResponse.data= this.data;
+                pageDatasResponse.message= this.message;
+                pageDatasResponse.extend=this.extend;
+                pageDatasResponse.azureToken = this.token;
+                baseResponse = pageDatasResponse;
+            }
+            else if (null != this.data && this.total > 0 && this.currPage > 0 && this.pageSize > 0 && this.totalPage > 0)
+            {
+                PageDatasResponse<object> pageDatasResponse = new PageDatasResponse<object>();
+                pageDatasResponse.code = this.code;
+                pageDatasResponse.data = this.data;
+                pageDatasResponse.message = this.message;
+                pageDatasResponse.page = new Pagination(this.total, this.currPage, this.pageSize, this.totalPage);
+                pageDatasResponse.extend = this.extend;
+                baseResponse = pageDatasResponse;
+            }
+            else if (this.data != null)
+            {
+                DataResponse<object> datasResponse = new DataResponse<object>();
+                datasResponse.code=this.code;
+                datasResponse.data=this.data;
+                datasResponse.message=this.message;
+                datasResponse.extend=this.extend;
+                baseResponse = datasResponse;
+            }
+            else
+            {
+                baseResponse = new BaseResponse();
+                ((BaseResponse)baseResponse).message=this.message;
+                ((BaseResponse)baseResponse).code=this.code;
+                ((BaseResponse)baseResponse).extend=this.extend;
+            }
+            return (BaseResponse)baseResponse;
+        }
+
+        
+
+        public ResponseBuilder Extend(Dictionary<String, object> extend)
+        {
+            this.extend = extend;
+            return this;
+        }
+        public ResponseBuilder Token(AzureTableToken token)
+        {
+            this.token = token;
+            return this;
+        }
+        public ResponseBuilder Data(object data)
+        {
+            this.data = data;
+            return this;
+        }
+       
+        public ResponseBuilder Page(Pagination page)
+        {
+            this.pageSize = page.pageSize;
+            this.currPage = page.currPage;
+            this.total = page.total;
+            this.page = page;
+            this.totalPage = (int)Math.Ceiling((double)this.total / (double)this.pageSize);
+            return this;
+        }
+        public ResponseBuilder totalCount(int totalCount)
+        {
+            this.total = totalCount;
+            return this;
+        }
+
+        public ResponseBuilder CurrPage(int currPage)
+        {
+            this.currPage = currPage;
+            return this;
+        }
+
+        public ResponseBuilder PageSize(int pageSize)
+        {
+            this.pageSize = pageSize;
+            return this;
+        }
+
+        public ResponseBuilder TotalPage(int totalPage)
+        {
+            this.totalPage = totalPage;
+            return this;
+        }
+
+        public ResponseBuilder success()
+        {
+            return this;
+        }
+
+        public ResponseBuilder success(String message)
+        {
+            this.message = message;
+            return this;
+        }
+
+        public ResponseBuilder success(String message, int code)
+        {
+            this.message = message;
+            this.code = code;
+            return this;
+        }
+
+        public ResponseBuilder failed(String message, int code)
+        {
+            this.code = code;
+            this.message = message;
+            return this;
+        }
+
+        public ResponseBuilder failed(String message)
+        {
+            this.code = 1;
+            this.message = message;
+            return this;
+        }
+    }
+}

+ 16 - 0
TEAMModelOS.Extension.DataResult/ResponseData/TimeStampResponse.cs

@@ -0,0 +1,16 @@
+using MessagePack;
+using System;
+
+
+namespace TEAMModelOS.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TimeStampResponse
+    {
+        public long responseTime { get; set; } = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        public TimeStampResponse()
+        {
+
+        }
+    }
+}

+ 14 - 0
TEAMModelOS.Extension.DataResult/ResponseData/TokenPageDatasResponse.cs

@@ -0,0 +1,14 @@
+using TEAMModelOS.Extension.DataResult.PageToken;
+using MessagePack;
+
+
+namespace TEAMModelOS.Extension.DataResult.ResponseData
+{
+    [MessagePackObject(keyAsPropertyName: true)]
+    public class TokenPageDatasResponse<T> : DataResponse<T>
+    {
+        public AzureTableToken azureToken { get; set; }
+
+        public TokenPageDatasResponse() { }
+    }
+}

+ 11 - 0
TEAMModelOS.Extension.DataResult/TEAMModelOS.Extension.DataResult.csproj

@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="MessagePack" Version="1.7.3.4" />
+  </ItemGroup>
+
+</Project>

+ 7 - 0
TEAMModelOS.Extension.JwtAuth/TEAMModelOS.Extension.JwtAuth.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 7 - 0
TEAMModelOS.Extension.Language/TEAMModelOS.Extension.Language.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 7 - 0
TEAMModelOS.Extension.MessagePush/TEAMModelOS.Extension.MessagePush.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 94 - 0
TEAMModelOS.Helper.Common/DateTimeHelper/DateTimeHelper.cs

@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.DateTimeHelper
+{
+    public static class DateTimeHelper
+    {
+        /// <summary>
+        /// 时间戳转换为日期(时间戳单位秒)
+        /// </summary>
+        /// <param name="TimeStamp"></param>
+        /// <returns></returns>
+        public static DateTime ConvertToDateTime(long timeStamp)
+        {
+            var dtStart = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1));
+            TimeSpan toNow = new TimeSpan(timeStamp);
+            return dtStart.Add(toNow);
+            //var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            //return start.AddMilliseconds(timeStamp).AddHours(8);
+        }
+        /// <summary>
+        /// 日期转换为时间戳(时间戳单位秒)
+        /// </summary>
+        /// <param name="TimeStamp"></param>
+        /// <returns></returns>
+        public static long ConvertToTimeStamp13(DateTime time)
+        {
+            DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            return (long)(time.AddHours(-8) - Jan1st1970).TotalMilliseconds;
+        }
+        /// <summary>
+        /// 日期转换为时间戳(时间戳单位秒)
+        /// </summary>
+        /// <param name="TimeStamp"></param>
+        /// <returns></returns>
+        public static long ConvertToTimeStamp10(DateTime time)
+        {
+            DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            return (long)(time.AddHours(-8) - Jan1st1970).TotalMilliseconds / 1000;
+        }
+
+        public static DateTime FromUnixTimestamp(this long unixtime)
+        {
+            DateTime sTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local);
+            return sTime.AddMilliseconds(unixtime);
+        }
+
+        public static DateTime FromUnixTimestampOffSet(this long unixtime, int offset)
+        {
+            DateTime sTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local);
+            int serverOffset = (int)TimeZoneInfo.Local.GetUtcOffset(DateTime.Now).TotalMinutes;
+            int subOffset = offset - serverOffset;
+            return sTime.AddMilliseconds(unixtime).AddMinutes(subOffset);
+        }
+        public static long ToUnixTimestamp(this DateTime datetime)
+        {
+            //DateTime sTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            DateTime sTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local);
+            return (long)(datetime - sTime).TotalMilliseconds;
+        }
+        /// <summary>
+        /// 获取当前cpu振荡时间戳 17位数
+        /// </summary>
+        /// <returns></returns>
+        public static long GetCPUMillisecond()
+        {
+            return DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+        }
+        /// <summary>
+        /// 获取标准毫秒级时间戳 13位数
+        /// </summary>
+        /// <returns></returns>
+        public static long GetMillisecond()
+        {
+            return (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
+        }
+
+
+        /// <summary>
+        /// 获得 GMT+8 时间
+        /// </summary>
+        /// <returns></returns>
+        public static DateTime ChinaTime()
+        {
+
+            TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");//设置时区
+            DateTime easternTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, easternZone);
+
+            return easternTime;
+        }
+
+    }
+}

+ 755 - 0
TEAMModelOS.Helper.Common/FileHelper/FileHelper.cs

@@ -0,0 +1,755 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Net;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.FileHelper
+{
+    public class FileHelper
+    {
+        #region 获取文件到集合中
+        /// <summary>
+        /// 读取指定位置文件列表到集合中
+        /// </summary>
+        /// <param name="path">指定路径</param>
+        /// <returns></returns>
+        public static DataTable GetFileTable(string path)
+        {
+            DataTable dt = new DataTable();
+            dt.Columns.Add("name", typeof(string));
+            dt.Columns.Add("ext", typeof(string));
+            dt.Columns.Add("size", typeof(long));
+            dt.Columns.Add("time", typeof(DateTime));
+
+            DirectoryInfo dirinfo = new DirectoryInfo(path);
+            FileInfo fi;
+            DirectoryInfo dir;
+            string FileName, FileExt;
+            long FileSize = 0;
+            DateTime FileModify;
+            try
+            {
+                foreach (FileSystemInfo fsi in dirinfo.GetFileSystemInfos())
+                {
+                    FileName = string.Empty;
+                    FileExt = string.Empty;
+                    if (fsi is FileInfo)
+                    {
+                        fi = (FileInfo)fsi;
+                        //获取文件名称
+                        FileName = fi.Name;
+                        //获取文件扩展名
+                        FileExt = fi.Extension;
+                        //获取文件大小
+                        FileSize = fi.Length;
+                        //获取文件最后修改时间
+                        FileModify = fi.LastWriteTime;
+                    }
+                    else
+                    {
+                        dir = (DirectoryInfo)fsi;
+                        //获取目录名
+                        FileName = dir.Name;
+                        //获取目录最后修改时间
+                        FileModify = dir.LastWriteTime;
+                        //设置目录文件为文件夹
+                        FileExt = "文件夹";
+                    }
+                    DataRow dr = dt.NewRow();
+                    dr["name"] = FileName;
+                    dr["ext"] = FileExt;
+                    dr["size"] = FileSize;
+                    dr["time"] = FileModify;
+                    dt.Rows.Add(dr);
+                }
+            }
+            catch
+            {
+
+                throw;
+            }
+            return dt;
+        }
+
+        #endregion
+
+        #region 检测指定路径是否存在
+        /// <summary>
+        /// 检测指定路径是否存在
+        /// </summary>
+        /// <param name="path">目录的绝对路径</param> 
+        public static bool IsExistDirectory(string path)
+        {
+            return Directory.Exists(path);
+        }
+        #endregion
+
+        #region 检测指定文件是否存在,如果存在则返回true
+        /// <summary>
+        /// 检测指定文件是否存在,如果存在则返回true
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>  
+        public static bool IsExistFile(string filePath)
+        {
+            return File.Exists(filePath);
+        }
+        #endregion
+
+        #region 创建文件夹
+        /// <summary>
+        /// 创建文件夹
+        /// </summary>
+        /// <param name="folderPath">文件夹的绝对路径</param>
+        public static void CreateFolder(string folderPath)
+        {
+            if (!IsExistDirectory(folderPath))
+            {
+                Directory.CreateDirectory(folderPath);
+            }
+        }
+        #endregion 
+
+        #region 判断上传文件后缀名
+        /// <summary>
+        /// 判断上传文件后缀名
+        /// </summary>
+        /// <param name="strExtension">后缀名</param>
+        public static bool IsCanEdit(string strExtension)
+        {
+            strExtension = strExtension.ToLower();
+            if (strExtension.LastIndexOf(".", StringComparison.Ordinal) >= 0)
+            {
+                strExtension = strExtension.Substring(strExtension.LastIndexOf(".", StringComparison.Ordinal));
+            }
+            else
+            {
+                strExtension = ".txt";
+            }
+            string[] strArray = new string[] { ".htm", ".html", ".txt", ".js", ".css", ".xml", ".sitemap" };
+            for (int i = 0; i < strArray.Length; i++)
+            {
+                if (strExtension.Equals(strArray[i]))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+
+        public static bool IsSafeName(string strExtension)
+        {
+            strExtension = strExtension.ToLower();
+            if (strExtension.LastIndexOf(".") >= 0)
+            {
+                strExtension = strExtension.Substring(strExtension.LastIndexOf("."));
+            }
+            else
+            {
+                strExtension = ".txt";
+            }
+            string[] strArray = new string[] { ".jpg", ".gif", ".png" };
+            for (int i = 0; i < strArray.Length; i++)
+            {
+                if (strExtension.Equals(strArray[i]))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public static bool IsZipName(string strExtension)
+        {
+            strExtension = strExtension.ToLower();
+            if (strExtension.LastIndexOf(".") >= 0)
+            {
+                strExtension = strExtension.Substring(strExtension.LastIndexOf("."));
+            }
+            else
+            {
+                strExtension = ".txt";
+            }
+            string[] strArray = new string[] { ".zip", ".rar" };
+            for (int i = 0; i < strArray.Length; i++)
+            {
+                if (strExtension.Equals(strArray[i]))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+        #endregion
+
+        #region 创建文件夹
+        /// <summary>
+        /// 创建文件夹
+        /// </summary>
+        /// <param name="fileName">文件的绝对路径</param>
+        public static void CreateSuffic(string fileName)
+        {
+            try
+            {
+                if (!Directory.Exists(fileName))
+                {
+                    Directory.CreateDirectory(fileName);
+                }
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 创建文件夹
+        /// </summary>
+        /// <param name="fileName">文件的绝对路径</param>
+        public static void CreateFiles(string fileName)
+        {
+            try
+            {
+                //判断文件是否存在,不存在创建该文件
+                if (!IsExistFile(fileName))
+                {
+                    FileInfo file = new FileInfo(fileName);
+                    FileStream fs = file.Create();
+                    fs.Close();
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+
+        /// <summary>
+        /// 创建一个文件,并将字节流写入文件。
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        /// <param name="buffer">二进制流数据</param>
+        public static void CreateFile(string filePath, byte[] buffer)
+        {
+            try
+            {
+                //判断文件是否存在,不存在创建该文件
+                if (!IsExistFile(filePath))
+                {
+                    FileInfo file = new FileInfo(filePath);
+                    FileStream fs = file.Create();
+                    fs.Write(buffer, 0, buffer.Length);
+                    fs.Close();
+                }
+                else
+                {
+                    File.WriteAllBytes(filePath, buffer);
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+        #endregion
+
+        #region 将文件移动到指定目录
+        /// <summary>
+        /// 将文件移动到指定目录
+        /// </summary>
+        /// <param name="sourceFilePath">需要移动的源文件的绝对路径</param>
+        /// <param name="descDirectoryPath">移动到的目录的绝对路径</param>
+        public static void Move(string sourceFilePath, string descDirectoryPath)
+        {
+            string sourceName = GetFileName(sourceFilePath);
+            if (IsExistDirectory(descDirectoryPath))
+            {
+                //如果目标中存在同名文件,则删除
+                if (IsExistFile(descDirectoryPath + "\\" + sourceFilePath))
+                {
+                    DeleteFile(descDirectoryPath + "\\" + sourceFilePath);
+                }
+                else
+                {
+                    //将文件移动到指定目录
+                    File.Move(sourceFilePath, descDirectoryPath + "\\" + sourceFilePath);
+                }
+            }
+        }
+        #endregion
+
+        # region 将源文件的内容复制到目标文件中
+        /// <summary>
+        /// 将源文件的内容复制到目标文件中
+        /// </summary>
+        /// <param name="sourceFilePath">源文件的绝对路径</param>
+        /// <param name="descDirectoryPath">目标文件的绝对路径</param>
+        public static void Copy(string sourceFilePath, string descDirectoryPath)
+        {
+            File.Copy(sourceFilePath, descDirectoryPath, true);
+        }
+        #endregion
+
+        #region 从文件的绝对路径中获取文件名( 不包含扩展名 )
+        /// <summary>
+        /// 从文件的绝对路径中获取文件名( 不包含扩展名 )
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param> 
+        public static string GetFileName(string filePath)
+        {
+            FileInfo file = new FileInfo(filePath);
+            return file.Name;
+        }
+        #endregion
+
+        #region 获取文件的后缀名
+        /// <summary>
+        /// 获取文件的后缀名
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        public static string GetExtension(string filePath)
+        {
+            FileInfo file = new FileInfo(filePath);
+            return file.Extension;
+        }
+
+        /// <summary>
+        /// 返回文件扩展名,不含“.”
+        /// </summary>
+        /// <param name="filepath">文件全名称</param>
+        /// <returns>string</returns>
+        public static string GetFileExt(string filepath)
+        {
+            if (string.IsNullOrEmpty(filepath))
+            {
+                return "";
+            }
+            if (filepath.LastIndexOf(".", StringComparison.Ordinal) > 0)
+            {
+                return filepath.Substring(filepath.LastIndexOf(".", StringComparison.Ordinal) + 1); //文件扩展名,不含“.”
+            }
+            return "";
+        }
+        #endregion
+
+        #region 删除指定文件
+        /// <summary>
+        /// 删除指定文件
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        public static void DeleteFile(string filePath)
+        {
+            if (IsExistFile(filePath))
+            {
+                File.Delete(filePath);
+            }
+        }
+        #endregion
+
+        #region 删除指定目录及其所有子目录
+        /// <summary>
+        /// 删除指定目录及其所有子目录
+        /// </summary>
+        /// <param name="directoryPath">文件的绝对路径</param>
+        public static void DeleteDirectory(string directoryPath)
+        {
+            if (IsExistDirectory(directoryPath))
+            {
+                Directory.Delete(directoryPath);
+            }
+        }
+        #endregion
+
+        #region 清空指定目录下所有文件及子目录,但该目录依然保存.
+        /// <summary>
+        /// 清空指定目录下所有文件及子目录,但该目录依然保存.
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>
+        public static void ClearDirectory(string directoryPath)
+        {
+            if (!IsExistDirectory(directoryPath)) return;
+            //删除目录中所有的文件
+            string[] fileNames = GetFileNames(directoryPath);
+            for (int i = 0; i < fileNames.Length; i++)
+            {
+                DeleteFile(fileNames[i]);
+            }
+            //删除目录中所有的子目录
+            string[] directoryNames = GetDirectories(directoryPath);
+            for (int i = 0; i < directoryNames.Length; i++)
+            {
+                DeleteDirectory(directoryNames[i]);
+            }
+        }
+        #endregion
+
+        #region  剪切  粘贴
+        /// <summary>
+        /// 剪切文件
+        /// </summary>
+        /// <param name="source">原路径</param> 
+        /// <param name="destination">新路径</param> 
+        public bool FileMove(string source, string destination)
+        {
+            bool ret = false;
+            FileInfo file_s = new FileInfo(source);
+            FileInfo file_d = new FileInfo(destination);
+            if (file_s.Exists)
+            {
+                if (!file_d.Exists)
+                {
+                    file_s.MoveTo(destination);
+                    ret = true;
+                }
+            }
+            if (ret == true)
+            {
+                //Response.Write("<script>alert('剪切文件成功!');</script>");
+            }
+            else
+            {
+                //Response.Write("<script>alert('剪切文件失败!');</script>");
+            }
+            return ret;
+        }
+        #endregion
+
+        #region 检测指定目录是否为空
+        /// <summary>
+        /// 检测指定目录是否为空
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>  
+        public static bool IsEmptyDirectory(string directoryPath)
+        {
+            try
+            {
+                //判断文件是否存在
+                string[] fileNames = GetFileNames(directoryPath);
+                if (fileNames.Length > 0)
+                {
+                    return false;
+                }
+                //判断是否存在文件夹
+                string[] directoryNames = GetDirectories(directoryPath);
+                if (directoryNames.Length > 0)
+                {
+                    return false;
+                }
+                return true;
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+                return true;
+            }
+        }
+        #endregion
+
+        #region 获取指定目录中所有文件列表
+        /// <summary>
+        /// 获取指定目录中所有文件列表
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>  
+        public static string[] GetFileNames(string directoryPath)
+        {
+            if (!IsExistDirectory(directoryPath))
+            {
+                throw new FileNotFoundException();
+            }
+            return Directory.GetFiles(directoryPath);
+        }
+        #endregion
+
+        #region 获取指定目录中的子目录列表
+        /// <summary>
+        /// 获取指定目录中所有子目录列表,若要搜索嵌套的子目录列表,请使用重载方法
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>
+        public static string[] GetDirectories(string directoryPath)
+        {
+            try
+            {
+                return Directory.GetDirectories(directoryPath);
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+
+        /// <summary>
+        /// 获取指定目录及子目录中所有子目录列表
+        /// </summary>
+        /// <param name="directoryPath">指定目录的绝对路径</param>
+        /// <param name="searchPattern">模式字符串,"*"代表0或N个字符,"?"代表1个字符。
+        /// 范例:"Log*.xml"表示搜索所有以Log开头的Xml文件。</param>
+        /// <param name="isSearchChild">是否搜索子目录</param>
+        public static string[] GetDirectories(string directoryPath, string searchPattern, bool isSearchChild)
+        {
+            try
+            {
+                if (isSearchChild)
+                {
+                    return Directory.GetDirectories(directoryPath, searchPattern, SearchOption.AllDirectories);
+                }
+                else
+                {
+                    return Directory.GetDirectories(directoryPath, searchPattern, SearchOption.TopDirectoryOnly);
+                }
+            }
+            catch (Exception ex)
+            {
+
+                throw ex;
+            }
+        }
+        #endregion
+
+        #region 获取一个文件的长度
+        /// <summary> 
+        /// 获取一个文件的长度,单位为Byte 
+        /// </summary> 
+        /// <param name="filePath">文件的绝对路径</param>         
+        public static int GetFileSize(string filePath)
+        {
+            //创建一个文件对象 
+            FileInfo fi = new FileInfo(filePath);
+            //获取文件的大小 
+            return (int)fi.Length;
+        }
+        /// <summary> 
+        /// 获取一个文件的长度,单位为KB 
+        /// </summary> 
+        /// <param name="filePath">文件的路径</param>         
+        public static double GetFileSizeByKb(string filePath)
+        {
+            //创建一个文件对象 
+            FileInfo fi = new FileInfo(filePath);
+            //获取文件的大小 
+            return Math.Round(Convert.ToDouble(filePath.Length) / 1024, 2);// ConvertHelper.ToDouble(ConvertHelper.ToDouble(fi.Length) / 1024, 1);
+        }
+
+        /// <summary> 
+        /// 获取一个文件的长度,单位为MB 
+        /// </summary> 
+        /// <param name="filePath">文件的路径</param>         
+        public static double GetFileSizeByMb(string filePath)
+        {
+            //创建一个文件对象 
+            FileInfo fi = new FileInfo(filePath);
+            //获取文件的大小 
+            return Math.Round(Convert.ToDouble(Convert.ToDouble(fi.Length) / 1024 / 1024), 2);
+        }
+
+        #endregion
+
+        #region 获取所有文件夹及子文件夹
+        /// <summary>
+        /// 获取所有文件夹及子文件夹
+        /// </summary>
+        /// <param name="dirPath"></param>
+        /// <returns></returns>
+        public static List<ArrayFiles> GetDirs(string dirPath)
+        {
+            var list = new List<ArrayFiles>();
+            return GetArrys(dirPath, 0, list);
+        }
+
+        private static int zdId = 0;
+        private static List<ArrayFiles> GetArrys(string dirPath, int pid, List<ArrayFiles> list)
+        {
+            if (!Directory.Exists(dirPath)) return list;
+            if (Directory.GetDirectories(dirPath).Length <= 0) return list;
+            foreach (string path in Directory.GetDirectories(dirPath))
+            {
+                zdId++;
+                var model = new ArrayFiles()
+                {
+                    Id = zdId,
+                    Name = path.Substring(path.LastIndexOf('\\') + 1, path.Length - (path.LastIndexOf('\\') + 1)),
+                    Pid = pid,
+                    Open = false,
+                    Target = "DeployBase",
+                    Url = "/FytAdmin/FileMiam/DocList?path=" + path
+                };
+                list.Add(model);
+                GetArrys(path, model.Id, list);
+            }
+            return list;
+        }
+
+        public class ArrayFiles
+        {
+            public int Id { get; set; }
+            public int Pid { get; set; }
+            public string Name { get; set; }
+            public Boolean Open { get; set; }
+            public string Target { get; set; }
+            public string Url { get; set; }
+        }
+        #endregion
+
+        #region 将文件读取到字符串中
+        /// <summary>
+        /// 将文件读取到字符串中
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        public static string FileToString(string filePath)
+        {
+            return FileToString(filePath, Encoding.UTF8);
+        }
+        /// <summary>
+        /// 将文件读取到字符串中
+        /// </summary>
+        /// <param name="filePath">文件的绝对路径</param>
+        /// <param name="encoding">字符编码</param>
+        public static string FileToString(string filePath, Encoding encoding)
+        {
+            //创建流读取器
+            StreamReader reader = new StreamReader(filePath, encoding);
+            try
+            {
+                //读取流
+                return reader.ReadToEnd();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+            finally
+            {
+                //关闭流读取器
+                reader.Close();
+            }
+        }
+        #endregion
+    }
+
+    /// <summary>
+    /// 远程文件下载
+    /// </summary>
+    public class HttpDldFile
+    {
+        /// <summary>
+        /// Http方式下载文件
+        /// </summary>
+        /// <param name="url">http地址</param>
+        /// <param name="localfile">本地文件</param>
+        /// <returns></returns>
+        public bool Download(string url, string localfile)
+        {
+            bool flag = false;
+            long startPosition = 0; // 上次下载的文件起始位置
+            FileStream writeStream; // 写入本地文件流对象
+
+            long remoteFileLength = GetHttpLength(url);// 取得远程文件长度
+            //System.Console.WriteLine("remoteFileLength=" + remoteFileLength);
+            if (remoteFileLength == 745)
+            {
+                System.Console.WriteLine("远程文件不存在.");
+                return false;
+            }
+
+            // 判断要下载的文件夹是否存在
+            if (File.Exists(localfile))
+            {
+
+                writeStream = File.OpenWrite(localfile);             // 存在则打开要下载的文件
+                startPosition = writeStream.Length;                  // 获取已经下载的长度
+
+                if (startPosition >= remoteFileLength)
+                {
+                    System.Console.WriteLine("本地文件长度" + startPosition + "已经大于等于远程文件长度" + remoteFileLength);
+                    writeStream.Close();
+
+                    return false;
+                }
+                else
+                {
+                    writeStream.Seek(startPosition, SeekOrigin.Current); // 本地文件写入位置定位
+                }
+            }
+            else
+            {
+                writeStream = new FileStream(localfile, FileMode.Create);// 文件不保存创建一个文件
+                startPosition = 0;
+            }
+
+
+            try
+            {
+                HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接
+
+                if (startPosition > 0)
+                {
+                    myRequest.AddRange((int)startPosition);// 设置Range值,与上面的writeStream.Seek用意相同,是为了定义远程文件读取位置
+                }
+
+
+                Stream readStream = myRequest.GetResponse().GetResponseStream();// 向服务器请求,获得服务器的回应数据流
+
+
+                byte[] btArray = new byte[512];// 定义一个字节数据,用来向readStream读取内容和向writeStream写入内容
+                int contentSize = readStream.Read(btArray, 0, btArray.Length);// 向远程文件读第一次
+
+                long currPostion = startPosition;
+
+                while (contentSize > 0)// 如果读取长度大于零则继续读
+                {
+                    currPostion += contentSize;
+                    int percent = (int)(currPostion * 100 / remoteFileLength);
+                    System.Console.WriteLine("percent=" + percent + "%");
+
+                    writeStream.Write(btArray, 0, contentSize);// 写入本地文件
+                    contentSize = readStream.Read(btArray, 0, btArray.Length);// 继续向远程文件读取
+                }
+
+                //关闭流
+                writeStream.Close();
+                readStream.Close();
+
+                flag = true;        //返回true下载成功
+            }
+            catch (Exception)
+            {
+                writeStream.Close();
+                flag = false;       //返回false下载失败
+            }
+
+            return flag;
+        }
+
+        // 从文件头得到远程文件的长度
+        private static long GetHttpLength(string url)
+        {
+            long length = 0;
+
+            try
+            {
+                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接
+                HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
+
+                if (rsp.StatusCode == HttpStatusCode.OK)
+                {
+                    length = rsp.ContentLength;// 从文件头得到远程文件的长度
+                }
+
+                rsp.Close();
+                return length;
+            }
+            catch (Exception e)
+            {
+                var s = e.Message;
+                return length;
+            }
+
+        }
+    }
+}

+ 550 - 0
TEAMModelOS.Helper.Common/FileHelper/FileHelperCore.cs

@@ -0,0 +1,550 @@
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.Helper.Common.FileHelper
+{
+    /// <summary>
+    /// Describe:文件帮助类
+    /// </summary>
+    public class FileHelperCore
+    {
+        private static IHostingEnvironment _hostingEnvironment = new HttpContextAccessor().HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
+
+        /// <summary>
+        /// 目录分隔符
+        /// windows "\" OSX and Linux  "/"
+        /// </summary>
+        private static string DirectorySeparatorChar = Path.DirectorySeparatorChar.ToString();
+        /// <summary>
+        /// 包含应用程序的目录的绝对路径
+        /// </summary>
+        private static string _ContentRootPath = _hostingEnvironment.ContentRootPath;
+
+        #region 检测指定路径是否存在
+
+        /// <summary>
+        /// 检测指定路径是否存在
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsExist(string path)
+        {
+            return IsDirectory(MapPath(path)) ? Directory.Exists(MapPath(path)) : File.Exists(MapPath(path));
+        }
+        /// <summary>
+        /// 检测指定路径是否存在(异步方式)
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static async Task<bool> IsExistAsync(string path)
+        {
+            return await Task.Run(() => IsDirectory(MapPath(path)) ? Directory.Exists(MapPath(path)) : File.Exists(MapPath(path)));
+        }
+
+        #endregion
+
+        #region 检测目录是否为空
+
+        /// <summary>
+        /// 检测目录是否为空
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsEmptyDirectory(string path)
+        {
+            return Directory.GetFiles(MapPath(path)).Length <= 0 && Directory.GetDirectories(MapPath(path)).Length <= 0;
+        }
+        /// <summary>
+        /// 检测目录是否为空
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static async Task<bool> IsEmptyDirectoryAsync(string path)
+        {
+            return await Task.Run(() => Directory.GetFiles(MapPath(path)).Length <= 0 && Directory.GetDirectories(MapPath(path)).Length <= 0);
+        }
+
+        #endregion
+
+        #region 创建目录
+
+        /// <summary>
+        /// 创建目录
+        /// </summary>
+        /// <param name="path">路径</param>
+        public static void CreateFiles(string path)
+        {
+            try
+            {
+                if (IsDirectory(MapPath(path)))
+                    Directory.CreateDirectory(MapPath(path));
+                else
+                    File.Create(MapPath(path)).Dispose();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        #endregion
+
+        #region 删除文件或目录
+
+        /// <summary>
+        /// 删除目录或文件
+        /// </summary>
+        /// <param name="path">路径</param>
+        public static void DeleteFiles(string path)
+        {
+            try
+            {
+                if (IsExist(path))
+                {
+                    if (IsDirectory(MapPath(path)))
+                        Directory.Delete(MapPath(path));
+                    else
+                        File.Delete(MapPath(path));
+                }
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        /// <summary>
+        /// 清空目录下所有文件及子目录,依然保留该目录
+        /// </summary>
+        /// <param name="path"></param>
+        public static void ClearDirectory(string path)
+        {
+            if (IsExist(path))
+            {
+                //目录下所有文件
+                string[] files = Directory.GetFiles(MapPath(path));
+                foreach (var file in files)
+                {
+                    DeleteFiles(file);
+                }
+                //目录下所有子目录
+                string[] directorys = Directory.GetDirectories(MapPath(path));
+                foreach (var dir in directorys)
+                {
+                    DeleteFiles(dir);
+                }
+            }
+        }
+
+        #endregion
+
+        #region 判断文件是否为隐藏文件(系统独占文件)
+
+        /// <summary>
+        /// 检测文件或文件夹是否为隐藏文件
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsHiddenFile(string path)
+        {
+            return IsDirectory(MapPath(path)) ? InspectHiddenFile(new DirectoryInfo(MapPath(path))) : InspectHiddenFile(new FileInfo(MapPath(path)));
+        }
+        /// <summary>
+        /// 检测文件或文件夹是否为隐藏文件(异步方式)
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static async Task<bool> IsHiddenFileAsync(string path)
+        {
+            return await Task.Run(() => IsDirectory(MapPath(path)) ? InspectHiddenFile(new DirectoryInfo(MapPath(path))) : InspectHiddenFile(new FileInfo(MapPath(path))));
+        }
+        /// <summary>
+        /// 私有方法 文件是否为隐藏文件(系统独占文件)
+        /// </summary>
+        /// <param name="fileSystemInfo"></param>
+        /// <returns></returns>
+        private static bool InspectHiddenFile(FileSystemInfo fileSystemInfo)
+        {
+            if (fileSystemInfo.Name.StartsWith("."))
+            {
+                return true;
+            }
+            else if (fileSystemInfo.Exists &&
+                ((fileSystemInfo.Attributes & FileAttributes.Hidden) != 0 ||
+                 (fileSystemInfo.Attributes & FileAttributes.System) != 0))
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        #endregion
+
+        #region 文件操作
+
+        #region 复制文件
+
+        /// <summary>
+        /// 复制文件内容到目标文件夹
+        /// </summary>
+        /// <param name="sourcePath">源文件</param>
+        /// <param name="targetPath">目标文件夹</param>
+        /// <param name="isOverWrite">是否可以覆盖</param>
+        public static void Copy(string sourcePath, string targetPath, bool isOverWrite = true)
+        {
+            File.Copy(MapPath(sourcePath), MapPath(targetPath) + GetFileName(sourcePath), isOverWrite);
+        }
+        /// <summary>
+        /// 复制文件内容到目标文件夹
+        /// </summary>
+        /// <param name="sourcePath">源文件</param>
+        /// <param name="targetPath">目标文件夹</param>
+        /// <param name="newName">新文件名称</param>
+        /// <param name="isOverWrite">是否可以覆盖</param>
+        public static void Copy(string sourcePath, string targetPath, string newName, bool isOverWrite = true)
+        {
+            File.Copy(MapPath(sourcePath), MapPath(targetPath) + newName, isOverWrite);
+        }
+
+        #endregion
+
+        #region 移动文件
+
+        /// <summary>
+        /// 移动文件到目标目录
+        /// </summary>
+        /// <param name="sourcePath">源文件</param>
+        /// <param name="targetPath">目标目录</param>
+        public static void Move(string sourcePath, string targetPath)
+        {
+            string sourceFileName = GetFileName(sourcePath);
+            //如果目标目录不存在则创建
+            if (IsExist(targetPath))
+            {
+                CreateFiles(targetPath);
+            }
+            else
+            {
+                //如果目标目录存在同名文件则删除
+                if (IsExist(Path.Combine(MapPath(targetPath), sourceFileName)))
+                {
+                    DeleteFiles(Path.Combine(MapPath(targetPath), sourceFileName));
+                }
+            }
+
+            File.Move(MapPath(sourcePath), Path.Combine(MapPath(targetPath), sourceFileName));
+
+
+        }
+
+        #endregion
+
+        /// <summary>
+        /// 获取文件名和扩展名
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string GetFileName(string path)
+        {
+            return Path.GetFileName(MapPath(path));
+        }
+
+        /// <summary>
+        /// 获取文件名不带扩展名
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string GetFileNameWithOutExtension(string path)
+        {
+            return Path.GetFileNameWithoutExtension(MapPath(path));
+        }
+
+        /// <summary>
+        /// 获取文件扩展名
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string GetFileExtension(string path)
+        {
+            return Path.GetExtension(MapPath(path));
+        }
+
+        #endregion
+
+        #region 获取文件绝对路径
+
+        /// <summary>
+        /// 获取文件绝对路径
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static string MapPath(string path)
+        {
+            return Path.Combine(_ContentRootPath, path.TrimStart('~', '/').Replace("/", DirectorySeparatorChar));
+        }
+        /// <summary>
+        /// 获取文件绝对路径(异步方式)
+        /// </summary>
+        /// <param name="path">文件路径</param>
+        /// <returns></returns>
+        public static async Task<string> MapPathAsync(string path)
+        {
+            return await Task.Run(() => Path.Combine(_ContentRootPath, path.TrimStart('~', '/').Replace("/", DirectorySeparatorChar)));
+        }
+
+
+        /// <summary>
+        /// 是否为目录或文件夹
+        /// </summary>
+        /// <param name="path">路径</param>
+        /// <returns></returns>
+        public static bool IsDirectory(string path)
+        {
+            if (path.EndsWith(DirectorySeparatorChar))
+                return true;
+            else
+                return false;
+        }
+
+        #endregion
+
+        #region 物理路径转虚拟路径
+        public static string PhysicalToVirtual(string physicalPath)
+        {
+            return physicalPath.Replace(_ContentRootPath, "").Replace(DirectorySeparatorChar, "/");
+        }
+        #endregion
+
+        #region 文件格式
+        /// <summary>
+        /// 是否可添加水印
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsCanWater(string _fileExt)
+        {
+            var images = new List<string> { "jpg", "jpeg" };
+            if (images.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为图片
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsImage(string _fileExt)
+        {
+            var images = new List<string> { "bmp", "gif", "jpg", "jpeg", "png" };
+            if (images.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为视频
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsVideos(string _fileExt)
+        {
+            var videos = new List<string> { "rmvb", "mkv", "ts", "wma", "avi", "rm", "mp4", "flv", "mpeg", "mov", "3gp", "mpg" };
+            if (videos.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为音频
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsMusics(string _fileExt)
+        {
+            var musics = new List<string> { "mp3", "wav" };
+            if (musics.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        /// <summary>
+        /// 是否为文档
+        /// </summary>
+        /// <param name="_fileExt">文件扩展名,不含“.”</param>
+        /// <returns></returns>
+        public static bool IsDocument(string _fileExt)
+        {
+            var documents = new List<string> { "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf" };
+            if (documents.Contains(_fileExt.ToLower())) return true;
+            return false;
+        }
+        #endregion
+
+        #region 文件图标
+        public static string FindFileIcon(string fileExt)
+        {
+            if (IsImage(fileExt))
+                return "fa fa-image";
+            if (IsVideos(fileExt))
+                return "fa fa-film";
+            if (IsMusics(fileExt))
+                return "fa fa-music";
+            if (IsDocument(fileExt))
+                switch (fileExt.ToLower())
+                {
+                    case ".xls":
+                    case ".xlsx":
+                        return "fa fa-file-excel-o";
+                    case ".ppt":
+                    case ".pptx":
+                        return "fa fa-file-powerpoint-o";
+                    case ".pdf":
+                        return "fa fa-file-pdf-o";
+                    case ".txt":
+                        return "fa fa-file-text-o";
+                    default:
+                        return "fa fa-file-word-o";
+                }
+            if (fileExt.ToLower() == "zip" || fileExt.ToLower() == "rar")
+                return "fa fa-file-zip-o";
+            else
+                return "fa fa-file";
+        }
+        #endregion
+
+        #region 文件大小转换
+        /// <summary>
+        ///  文件大小转为B、KB、MB、GB...
+        /// </summary>
+        /// <param name="size"></param>
+        /// <returns></returns>
+        public static string FileSizeTransf(long size)
+        {
+            String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" };
+            long mod = 1024;
+            int i = 0;
+            while (size > mod)
+            {
+                size /= mod;
+                i++;
+            }
+            return size + units[i];
+
+        }
+        #endregion
+
+        #region 获取目录下所有文件
+        public static List<FilesInfo> FindFiles(string path, string staticFiles = "/wwwroot")
+        {
+            string[] folders = Directory.GetDirectories(MapPath(path), "*", SearchOption.AllDirectories);
+            var Files = new List<FilesInfo>();
+
+            foreach (var folder in folders)
+            {
+                foreach (var fsi in new DirectoryInfo(folder).GetFiles())
+                {
+                    Files.Add(new FilesInfo()
+                    {
+                        Name = fsi.Name,
+                        FullName = fsi.FullName,
+                        FileExt = fsi.Extension,
+                        FileOriginalSize = fsi.Length,
+                        FileSize = FileSizeTransf(fsi.Length),
+                        FileIcon = FindFileIcon(fsi.Extension.Remove(0, 1)),
+                        FileName = PhysicalToVirtual(fsi.FullName).Replace(staticFiles, ""),
+                        FileStyle = IsImage(fsi.Extension.Remove(0, 1)) ? "images" :
+                                    IsDocument(fsi.Extension.Remove(0, 1)) ? "documents" :
+                                    IsVideos(fsi.Extension.Remove(0, 1)) ? "videos" :
+                                    IsMusics(fsi.Extension.Remove(0, 1)) ? "musics" : "others",
+                        CreateDate = fsi.CreationTime,
+                        LastWriteDate = fsi.LastWriteTime,
+                        LastAccessDate = fsi.LastAccessTime
+                    });
+                }
+            }
+            return Files;
+        }
+
+        /// <summary>
+        /// 获得指定文件夹下面的所有文件
+        /// </summary>
+        /// <param name="path"></param>
+        /// <param name="staticFiles"></param>
+        /// <returns></returns>
+        public static List<FilesInfo> ResolveFileInfo(string path, string staticFiles = "/wwwroot")
+        {
+            var foldersPath = MapPath(path);
+            var Files = new List<FilesInfo>();
+            foreach (var fsi in new DirectoryInfo(foldersPath).GetFiles())
+            {
+                Files.Add(new FilesInfo()
+                {
+                    Name = fsi.Name,
+                    FullName = fsi.FullName,
+                    FileExt = fsi.Extension,
+                    FileOriginalSize = fsi.Length,
+                    FileSize = FileSizeTransf(fsi.Length),
+                    FileIcon = FindFileIcon(fsi.Extension.Remove(0, 1)),
+                    FileName = PhysicalToVirtual(fsi.FullName).Replace(staticFiles, ""),
+                    FileStyle = IsImage(fsi.Extension.Remove(0, 1)) ? "images" :
+                                IsDocument(fsi.Extension.Remove(0, 1)) ? "documents" :
+                                IsVideos(fsi.Extension.Remove(0, 1)) ? "videos" :
+                                IsMusics(fsi.Extension.Remove(0, 1)) ? "musics" : "others",
+                    CreateDate = fsi.CreationTime,
+                    LastWriteDate = fsi.LastWriteTime,
+                    LastAccessDate = fsi.LastAccessTime
+                });
+            }
+            return Files;
+        }
+        #endregion
+
+    }
+
+    public class FilesInfo
+    {
+        /// <summary>
+        /// 文件名称
+        /// </summary>
+        public string Name { get; set; }
+        /// <summary>
+        /// 文件物理路径
+        /// </summary>
+        public string FullName { get; set; }
+        /// <summary>
+        /// 扩展名
+        /// </summary>
+        public string FileExt { get; set; }
+        /// <summary>
+        /// 原始大小(字节)
+        /// </summary>
+        public long FileOriginalSize { get; set; }
+        /// <summary>
+        /// 文件大小
+        /// </summary>
+        public string FileSize { get; set; }
+        /// <summary>
+        /// 文件虚拟路径
+        /// </summary>
+        public string FileName { get; set; }
+        /// <summary>
+        /// 文件类型
+        /// </summary>
+        public string FileStyle { get; set; }
+        /// <summary>
+        /// 文件图标
+        /// </summary>
+        public string FileIcon { get; set; }
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public DateTime CreateDate { get; set; }
+        /// <summary>
+        /// 最后修改时间
+        /// </summary>
+        public DateTime LastWriteDate { get; set; }
+        /// <summary>
+        /// 最后访问时间
+        /// </summary>
+        public DateTime LastAccessDate { get; set; }
+
+    }
+}

+ 116 - 0
TEAMModelOS.Helper.Common/JsonHelper/JsonSerialization.cs

@@ -0,0 +1,116 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.JsonHelper
+{
+    public static class JsonSerialization
+    {
+        static JsonSerializerSettings settings = new JsonSerializerSettings()
+        {
+            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+            PreserveReferencesHandling = PreserveReferencesHandling.Objects
+        };
+
+        /// <summary>
+        /// 使用json序列化为字符串
+        /// </summary>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制,如:"\/Date(1439335800000+0800)\/"</param>
+        /// <returns></returns>
+        public static string ToJson(this object input, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true, bool isIndented = false)
+        {
+            settings.NullValueHandling = ignoreNullValue ? Newtonsoft.Json.NullValueHandling.Ignore : NullValueHandling.Include;
+
+            if (!string.IsNullOrWhiteSpace(dateTimeFormat))
+            {
+                var jsonConverter = new List<JsonConverter>()
+                {
+                    new Newtonsoft.Json.Converters.IsoDateTimeConverter(){ DateTimeFormat = dateTimeFormat }//如: "yyyy-MM-dd HH:mm:ss"
+                };
+                settings.Converters = jsonConverter;
+            }
+
+            //no format
+            var format = isIndented ? Newtonsoft.Json.Formatting.Indented : Formatting.None;
+            var json = JsonConvert.SerializeObject(input, format, settings);
+            return json;
+        }
+
+        /// <summary>
+        /// 从序列化字符串里反序列化
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="input"></param>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制</param>
+        /// <returns></returns>
+        public static T TryFromJson<T>(this string input, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true)
+        {
+            try
+            {
+                return input.FromJson<T>(dateTimeFormat, ignoreNullValue);
+            }
+            catch
+            {
+                return default(T);
+            }
+        }
+        /// <summary>
+        /// 从序列化字符串里反序列化
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="input"></param>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制</param>
+        /// <returns></returns>
+        public static T FromJson<T>(this string input, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true)
+        {
+            var settings = new JsonSerializerSettings()
+            {
+                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
+            };
+            settings.NullValueHandling = ignoreNullValue ? Newtonsoft.Json.NullValueHandling.Ignore : NullValueHandling.Include;
+
+            if (!string.IsNullOrWhiteSpace(dateTimeFormat))
+            {
+                var jsonConverter = new List<JsonConverter>()
+                {
+                    new Newtonsoft.Json.Converters.IsoDateTimeConverter(){ DateTimeFormat = dateTimeFormat }//如: "yyyy-MM-dd HH:mm:ss"
+                };
+                settings.Converters = jsonConverter;
+            }
+
+            return JsonConvert.DeserializeObject<T>(input, settings);
+        }
+        /// <summary>
+        /// 从序列化字符串里反序列化
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="input"></param>
+        /// <param name="dateTimeFormat">默认null,即使用json.net默认的序列化机制</param>
+        /// <returns></returns>
+        public static object FromJson(this string input, Type type, string dateTimeFormat = "yyyy-MM-dd HH:mm:ss", bool ignoreNullValue = true)
+        {
+            var settings = new JsonSerializerSettings()
+            {
+                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
+            };
+            if (ignoreNullValue)
+            {
+                settings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
+            }
+
+            if (!string.IsNullOrWhiteSpace(dateTimeFormat))
+            {
+                var jsonConverter = new List<JsonConverter>()
+                {
+                    new Newtonsoft.Json.Converters.IsoDateTimeConverter(){ DateTimeFormat = dateTimeFormat }//如: "yyyy-MM-dd HH:mm:ss"
+                };
+                settings.Converters = jsonConverter;
+            }
+
+            return JsonConvert.DeserializeObject(input, type, settings);
+        }
+    }
+}

+ 74 - 0
TEAMModelOS.Helper.Common/JsonHelper/MessagePackHelper.cs

@@ -0,0 +1,74 @@
+using MessagePack;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.JsonHelper
+{
+    public class MessagePackHelper
+    {
+        /// <summary>
+        /// Json字符串转Byte
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns>byte[]</returns>
+        public static byte[] JsonToByte(string json)
+        {
+            return LZ4MessagePackSerializer.FromJson(json);
+        }
+
+        /// <summary>
+        /// Json字符串转对象
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="json"></param>
+        /// <returns>T</returns>
+        public static T JsonToObject<T>(string json)
+        {
+            Type type = typeof(T);
+            return (T)LZ4MessagePackSerializer.NonGeneric.Deserialize(type, JsonToByte(json));
+        }
+
+        /// <summary>
+        /// 对象转Byte
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns>byte[]</returns>
+        public static byte[] ObjectToByte(Object obj)
+        {
+            return LZ4MessagePackSerializer.Serialize(obj);
+        }
+
+        /// <summary>
+        /// 对象转Json
+        /// </summary>
+        /// <param name="obj"></param>
+        /// <returns>string</returns>
+        public static string ObjectToJson(Object obj)
+        {
+            return LZ4MessagePackSerializer.ToJson(ObjectToByte(obj));
+        }
+
+        /// <summary>
+        /// byte转Json
+        /// </summary>
+        /// <param name="bt"></param>
+        /// <returns></returns>
+        public static string ByteToJson(byte[] bt)
+        {
+            return LZ4MessagePackSerializer.ToJson(bt);
+        }
+
+        /// <summary>
+        /// byte转对象
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="bt"></param>
+        /// <returns></returns>
+        public static T ByteToObject<T>(byte[] bt)
+        {
+            Type type = typeof(T);
+            return (T)LZ4MessagePackSerializer.NonGeneric.Deserialize(type, bt);
+        }
+    }
+}

+ 35 - 0
TEAMModelOS.Helper.Common/ReflectorExtensions/ReflectorExtensions.cs

@@ -0,0 +1,35 @@
+using AspectCore.Extensions.Reflection;
+using System;
+using System.Reflection;
+
+namespace TEAMModelOS.Helper.Common.ReflectorExtensions
+{
+    public static class ReflectorExtensions
+    {
+        public static T GetPropertyValue<T>(this object obj, string name, BindingFlags bindingFlags) where T : class
+        {
+            var chProperty = obj.GetType().GetTypeInfo().GetProperty(name, bindingFlags);
+            var chReflector = chProperty.GetReflector();
+            var value = chReflector.GetValue(obj) as T;
+
+            return value;
+        }
+
+        public static Tuple<T, FieldInfo> GetFieldValue<T>(this object obj, string name, BindingFlags bindingFlags) where T : class
+        {
+            var chField = obj.GetType().GetTypeInfo().GetField(name, bindingFlags);
+            var chReflector = chField.GetReflector();
+            var value = chReflector.GetValue(obj) as T;
+
+            return Tuple.Create(value, chField);
+        }
+
+        public static T GetFieldValue<T>(this Type type, string name, BindingFlags bindingFlags) where T : class
+        {
+            var chField = type.GetTypeInfo().GetField(name, bindingFlags);
+            var chReflector = chField.GetReflector();
+            var value = chReflector.GetValue(null) as T;
+            return value;
+        }
+    }
+}

+ 77 - 0
TEAMModelOS.Helper.Common/StringHelper/StringHelper.cs

@@ -0,0 +1,77 @@
+using System;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Common.StringHelper
+{
+    public class StringHelper
+    {
+        #region 截取字符串
+        public static string GetSubString(string pSrcString, int pLength, string pTailString)
+        {
+            return GetSubString(pSrcString, 0, pLength, pTailString);
+        }
+        public static string GetSubString(string pSrcString, int pStartIndex, int pLength, string pTailString)
+        {
+            string str = pSrcString;
+            byte[] bytes = Encoding.UTF8.GetBytes(pSrcString);
+            foreach (char ch in Encoding.UTF8.GetChars(bytes))
+            {
+                if (((ch > 'ࠀ') && (ch < '一')) || ((ch > 0xac00) && (ch < 0xd7a3)))
+                {
+                    if (pStartIndex >= pSrcString.Length)
+                    {
+                        return "";
+                    }
+                    return pSrcString.Substring(pStartIndex, ((pLength + pStartIndex) > pSrcString.Length) ? (pSrcString.Length - pStartIndex) : pLength);
+                }
+            }
+            if (pLength < 0)
+            {
+                return str;
+            }
+            byte[] sourceArray = Encoding.Default.GetBytes(pSrcString);
+            if (sourceArray.Length <= pStartIndex)
+            {
+                return str;
+            }
+            int length = sourceArray.Length;
+            if (sourceArray.Length > (pStartIndex + pLength))
+            {
+                length = pLength + pStartIndex;
+            }
+            else
+            {
+                pLength = sourceArray.Length - pStartIndex;
+                pTailString = "";
+            }
+            int num2 = pLength;
+            int[] numArray = new int[pLength];
+            byte[] destinationArray = null;
+            int num3 = 0;
+            for (int i = pStartIndex; i < length; i++)
+            {
+                if (sourceArray[i] > 0x7f)
+                {
+                    num3++;
+                    if (num3 == 3)
+                    {
+                        num3 = 1;
+                    }
+                }
+                else
+                {
+                    num3 = 0;
+                }
+                numArray[i] = num3;
+            }
+            if ((sourceArray[length - 1] > 0x7f) && (numArray[pLength - 1] == 1))
+            {
+                num2 = pLength + 1;
+            }
+            destinationArray = new byte[num2];
+            Array.Copy(sourceArray, pStartIndex, destinationArray, 0, num2);
+            return (Encoding.Default.GetString(destinationArray) + pTailString);
+        }
+        #endregion
+    }
+}

+ 14 - 0
TEAMModelOS.Helper.Common/TEAMModelOS.Helper.Common.csproj

@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="AspectCore.Extensions.Reflection" Version="1.2.0" />
+    <PackageReference Include="MessagePack" Version="1.7.3.4" />
+    <PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
+    <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
+  </ItemGroup>
+
+</Project>

+ 65 - 0
TEAMModelOS.Helper.Common/ValidateHelper/ValidateHelper.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel.DataAnnotations;
+
+namespace TEAMModelOS.Helper.Common.ValidateHelper
+{
+    public static class ValidateHelper
+    {
+        public static string AllowCountry { get; set; }
+        /// <summary>
+        /// 验证对象是否有效
+        /// </summary>
+        /// <param name="obj">要验证的对象</param>
+        /// <param name="validationResults"></param>
+        /// <returns></returns>
+        public static bool IsValid(this object obj, Collection<ValidationResult> validationResults)
+        {
+            return Validator.TryValidateObject(obj, new ValidationContext(obj, null, null), validationResults, true);
+        }
+
+        /// <summary>
+        /// 验证对象是否有效
+        /// </summary>
+        /// <param name="obj">要验证的对象</param>
+        /// <returns></returns>
+        public static T ValidObj<T>(T value)
+        {
+            var results = new Collection<ValidationResult>();
+            var validationContext = new ValidationContext(value, null, null);
+            bool f = Validator.TryValidateObject(value, validationContext, results, true);
+            if (f)
+            {
+                return value;
+            }
+            else
+            {
+                return default(T);
+            }
+        }
+        /// <summary>
+        /// 验证对象是否有效
+        /// </summary>
+        /// <param name="obj">要验证的对象</param>
+        /// <returns></returns>
+        public static bool IsValid(object value)
+        {
+            var results = new Collection<ValidationResult>();
+            var validationContext = new ValidationContext(value, null, null);
+            bool f = Validator.TryValidateObject(value, validationContext, results, true);
+            if (!f)
+            {
+                string s = "";
+                foreach (ValidationResult result in results)
+                {
+                    IEnumerator<string> enumerator = result.MemberNames.GetEnumerator();
+                    enumerator.MoveNext();
+                    s = s + enumerator.Current + ",";
+                }
+                throw new Exception(s + "字段不正确");
+            }
+            return f;
+        }
+    }
+}

+ 96 - 0
TEAMModelOS.Helper.Network/HttpHelper/HttpContextHelper.cs

@@ -0,0 +1,96 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Primitives;
+using System;
+using System.Linq;
+
+namespace TEAMModelOS.Helper.Network.HttpHelper
+{
+    public static class HttpContextHelper
+    {
+        /// <summary>
+        /// 设置本地cookie
+        /// </summary>
+        /// <param name="key">键</param>
+        /// <param name="value">值</param>  
+        /// <param name="minutes">过期时长,单位:分钟</param>      
+        public static void SetCookies(HttpResponse Response, string key, string value, int minutes = 30)
+        {
+            Response.Cookies.Append(key, value, new CookieOptions
+            {
+                Expires = DateTime.Now.AddMinutes(minutes)
+            });
+        }
+        /// <summary>
+        /// 删除指定的cookie
+        /// </summary>
+        /// <param name="key">键</param>
+        public static void DeleteCookies(HttpContext httpContext, string key)
+        {
+            httpContext.Response.Cookies.Delete(key);
+        }
+
+        /// <summary>
+        /// 在Http中获取值
+        /// </summary>
+        /// <param name="key">键</param>
+        /// <returns>返回对应的值</returns>
+        public static string GetValueInHttp(HttpRequest Request, string key)
+        {
+            string aktoken = "";
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                //或者在头获取
+                Request.Headers.TryGetValue(key, out StringValues akh);
+                if (!string.IsNullOrEmpty(akh))
+                {
+                    aktoken = akh;
+                }
+            }
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                //其次在参数中获取
+                Request.Query.TryGetValue(key, out StringValues ak);
+                if (!string.IsNullOrEmpty(ak))
+                {
+                    aktoken = ak;
+                }
+            }
+            //从cookie获取
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                Request.Cookies.TryGetValue(key, out string value);
+                if (!string.IsNullOrEmpty(value))
+                {
+                    aktoken = value;
+                }
+            }
+            if (string.IsNullOrEmpty(aktoken))
+            {
+                //在referer获取
+                Request.Headers.TryGetValue("referer", out StringValues referer);
+                string token = "";
+                if (referer.Contains(key + "="))
+                {
+                    string[] pramas = referer[0].Substring(referer[0].IndexOf(key + "=")).Split("&");
+                    int len = pramas.Count();
+                    if (len > 0)
+                    {
+                        for (int i = 0; i < len; i++)
+                        {
+                            if (pramas[i].Contains(key))
+                            {
+                                token = pramas[i].Split("=")[1];
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (!string.IsNullOrEmpty(token))
+                {
+                    aktoken = token;
+                }
+            }
+            return aktoken;
+        }
+    }
+}

+ 186 - 0
TEAMModelOS.Helper.Network/HttpHelper/HttpHelper.cs

@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.Helper.Network.HttpHelper
+{
+    public class HttpHelper
+    {
+        /// <summary>
+        /// 同步GET请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="headers"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <returns></returns>
+        public static string HttpGet(string url, Dictionary<string, string> headers = null, int timeout = 0)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                Byte[] resultBytes = client.GetByteArrayAsync(url).Result;
+                return Encoding.UTF8.GetString(resultBytes);
+            }
+        }
+
+        /// <summary>
+        /// 异步GET请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="headers"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <returns></returns>
+        public static async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null, int timeout = 0)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                Byte[] resultBytes = await client.GetByteArrayAsync(url);
+                return Encoding.Default.GetString(resultBytes);
+            }
+        }
+
+
+        /// <summary>
+        /// 同步POST请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <param name="encoding">默认UTF8</param>
+        /// <returns></returns>
+        public static string HttpPost(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                using (HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8))
+                {
+                    if (contentType != null)
+                    {
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+                    }
+                    using (HttpResponseMessage responseMessage = client.PostAsync(url, content).Result)
+                    {
+                        Byte[] resultBytes = responseMessage.Content.ReadAsByteArrayAsync().Result;
+                        return Encoding.UTF8.GetString(resultBytes);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 异步POST请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <param name="encoding">默认UTF8</param>
+        /// <returns></returns>
+        public static async Task<string> HttpPostAsync(string url, string postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                using (HttpContent content = new StringContent(postData ?? "", encoding ?? Encoding.UTF8))
+                {
+                    if (contentType != null)
+                    {
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+                    }
+                    using (HttpResponseMessage responseMessage = await client.PostAsync(url, content))
+                    {
+                        Byte[] resultBytes = await responseMessage.Content.ReadAsByteArrayAsync();
+                        return Encoding.UTF8.GetString(resultBytes);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 异步POST请求
+        /// </summary>
+        /// <param name="url"></param>
+        /// <param name="postData"></param>
+        /// <param name="headers"></param>
+        /// <param name="contentType"></param>
+        /// <param name="timeout">请求响应超时时间,单位/s(默认100秒)</param>
+        /// <param name="encoding">默认UTF8</param>
+        /// <returns></returns>
+        public static async Task<string> HttpPostAsync(string url, List<KeyValuePair<string, string>> postData, Dictionary<string, string> headers = null, string contentType = null, int timeout = 0, Encoding encoding = null)
+        {
+            using (HttpClient client = new HttpClient())
+            {
+                if (headers != null)
+                {
+                    foreach (KeyValuePair<string, string> header in headers)
+                    {
+                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
+                    }
+                }
+                if (timeout > 0)
+                {
+                    client.Timeout = new TimeSpan(0, 0, timeout);
+                }
+                using (HttpContent content = new FormUrlEncodedContent(postData))
+                {
+                    if (contentType != null)
+                    {
+                        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
+                    }
+                    using (HttpResponseMessage responseMessage = await client.PostAsync(url, content))
+                    {
+                        Byte[] resultBytes = await responseMessage.Content.ReadAsByteArrayAsync();
+                        return Encoding.UTF8.GetString(resultBytes);
+                    }
+                }
+            }
+        }
+    }
+}

+ 86 - 0
TEAMModelOS.Helper.Network/NetworkHelper/NetworkHelper.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.NetworkInformation;
+using System.Net.Sockets;
+
+namespace TEAMModelOS.Helper.Network.NetworkHelper
+{
+    public static class NetHelper
+    {
+        /// <summary>
+        /// The ip segment regex
+        /// </summary>
+        private const string IPSegmentRegex = @"\d{0,3}";
+
+        /// <summary>
+        /// Gets the ip.
+        /// </summary>
+        /// <param name="ipSegment">ip段</param>
+        /// <returns></returns>
+        public static string GetIp(string ipSegment)
+        {
+            if (string.IsNullOrWhiteSpace(ipSegment))
+                throw new ArgumentNullException(nameof(ipSegment));
+
+            //如果设置的IP支持* 的时候,再去智能的选择ip
+            if (!ipSegment.Contains("*"))
+            {
+                return ipSegment;
+            }
+
+            ipSegment = ipSegment.Replace("*", IPSegmentRegex).Replace(".", "\\.");
+
+            var hostAddrs = NetworkInterface.GetAllNetworkInterfaces()
+            .Where(i => i.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
+                .SelectMany(i => i.GetIPProperties().UnicastAddresses)
+                .Select(a => a.Address)
+                .Where(a => !(a.IsIPv6LinkLocal || a.IsIPv6Multicast || a.IsIPv6SiteLocal || a.IsIPv6Teredo))
+                .ToList();
+
+            foreach (var ip in hostAddrs)
+            {
+                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork
+                    && System.Text.RegularExpressions.Regex.IsMatch(ip.ToString(), ipSegment))
+                {
+                    return ip.ToString();
+                }
+            }
+
+            throw new Exception($"找不到ipsegement:{ipSegment}匹配的ip, OR No network adapters with an IPv4 address in the system!");
+        }
+
+        /// <summary>
+        /// 解析ip和port
+        /// </summary>
+        /// <param name="serviceAddress"></param>
+        /// <returns></returns>
+        public static Tuple<string, int> GetIPAndPort(string serviceAddress)
+        {
+            //解析ip
+            var ipPort = serviceAddress.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
+            var ip = NetHelper.GetIp(ipPort[0]);
+            //解析port
+            var port = 0;
+            if (ipPort.Length == 2)
+            {
+                int.TryParse(ipPort[1], out port);
+            }
+            return Tuple.Create(ip, port);
+        }
+
+        /// <summary>
+        ///   获取所有网卡IP地址
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> getIPAddress()
+        {
+            return NetworkInterface.GetAllNetworkInterfaces()
+            .SelectMany(i => i.GetIPProperties().UnicastAddresses)
+            .Select(a => a.Address)
+            //AddressFamily.InterNetwork  过滤掉IPV6  //过滤127.0.0.1  !IPAddress.IsLoopback(a)
+            .Where(a => a.AddressFamily == AddressFamily.InterNetwork)
+            .Select(a => a.ToString()).ToList();
+        }
+    }
+}

+ 11 - 0
TEAMModelOS.Helper.Network/TEAMModelOS.Helper.Network.csproj

@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
+  </ItemGroup>
+
+</Project>

+ 175 - 0
TEAMModelOS.Helper.Query/LinqHelper/DynamicLinq.cs

@@ -0,0 +1,175 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+
+namespace TEAMModelOS.Helper.Query.LinqHelper
+{
+    public static class DynamicLinq
+    {
+        /// <summary>
+        /// 创建参数表达式
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public static ParameterExpression CreateLambdaParam<T>(string name)
+        {
+            return Expression.Parameter(typeof(T), name);
+        }
+
+        /// <summary>
+        /// 创建linq表达示的body部分
+        /// </summary>
+        public static Expression GenerateBody<T>(this ParameterExpression param, Filter filterObj)
+        {
+            PropertyInfo property = typeof(T).GetProperty(filterObj.Key);
+
+            //组装左边
+            Expression left = Expression.Property(param, property);
+            //组装右边
+            Expression right = null;
+
+            if (property.PropertyType == typeof(int))
+            {
+                right = Expression.Constant(int.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(DateTime))
+            {
+                right = Expression.Constant(DateTime.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(string))
+            {
+                right = Expression.Constant((filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(decimal))
+            {
+                right = Expression.Constant(decimal.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(Guid))
+            {
+                right = Expression.Constant(Guid.Parse(filterObj.Value));
+            }
+            else if (property.PropertyType == typeof(bool))
+            {
+                right = Expression.Constant(filterObj.Value.Equals("1"));
+            }
+            else if (property.PropertyType == typeof(Guid?))
+            {
+                left = Expression.Property(left, "Value");
+                right = Expression.Constant(Guid.Parse(filterObj.Value));
+            }
+            else
+            {
+                throw new Exception("暂不能解析该Key的类型");
+            }
+
+            //c.XXX=="XXX"
+            Expression filter = Expression.Equal(left, right);
+            switch (filterObj.Contrast)
+            {
+                case "<=":
+                    filter = Expression.LessThanOrEqual(left, right);
+                    break;
+
+                case "<":
+                    filter = Expression.LessThan(left, right);
+                    break;
+
+                case ">":
+                    filter = Expression.GreaterThan(left, right);
+                    break;
+
+                case ">=":
+                    filter = Expression.GreaterThanOrEqual(left, right);
+                    break;
+                case "!=":
+                    filter = Expression.NotEqual(left, right);
+                    break;
+
+                case "like":
+                    filter = Expression.Call(left, typeof(string).GetMethod("Contains", new Type[] { typeof(string) }),
+                                 Expression.Constant(filterObj.Value));
+                    break;
+                case "not in":
+                    var listExpression = Expression.Constant(filterObj.Value.Split(',').ToList()); //数组
+                    var method = typeof(List<string>).GetMethod("Contains", new Type[] { typeof(string) }); //Contains语句
+                    filter = Expression.Not(Expression.Call(listExpression, method, left));
+                    break;
+                case "in":
+                    var lExp = Expression.Constant(filterObj.Value.Split(',').ToList()); //数组
+                    var methodInfo = typeof(List<string>).GetMethod("Contains", new Type[] { typeof(string) }); //Contains语句
+                    filter = Expression.Call(lExp, methodInfo, left);
+                    break;
+            }
+
+            return filter;
+        }
+
+
+
+        public static Expression<Func<T, bool>> GenerateTypeBody<T>(this ParameterExpression param, Filter filterObj)
+        {
+            return (Expression<Func<T, bool>>)(param.GenerateBody<T>(filterObj));
+        }
+
+        /// <summary>
+        /// 创建完整的lambda
+        /// </summary>
+        public static LambdaExpression GenerateLambda(this ParameterExpression param, Expression body)
+        {
+            //c=>c.XXX=="XXX"
+            return Expression.Lambda(body, param);
+        }
+
+        public static Expression<Func<T, bool>> GenerateTypeLambda<T>(this ParameterExpression param, Expression body)
+        {
+            return (Expression<Func<T, bool>>)(param.GenerateLambda(body));
+        }
+
+        public static Expression AndAlso(this Expression expression, Expression expressionRight)
+        {
+            return Expression.AndAlso(expression, expressionRight);
+        }
+
+        public static Expression Or(this Expression expression, Expression expressionRight)
+        {
+            return Expression.Or(expression, expressionRight);
+        }
+
+        public static Expression And(this Expression expression, Expression expressionRight)
+        {
+            return Expression.And(expression, expressionRight);
+        }
+
+
+        public static IQueryable<T> Where<T>(this IQueryable<T> query, Expression expression)
+        {
+            Expression expr = Expression.Call(typeof(Queryable), "Where", new[] { typeof(T) },
+               Expression.Constant(query), expression);
+            //生成动态查询
+            IQueryable<T> result = query.Provider.CreateQuery<T>(expr);
+            return result;
+        }
+
+        public static IQueryable<T> GenerateFilter<T>(this IQueryable<T> query, IEnumerable<Filter> filters)
+        {
+            if (filters != null)
+            {
+                // var filters = JsonHelper.Instance.Deserialize<IEnumerable<Filter>>(filterjson);
+                var param = CreateLambdaParam<T>("c");
+                //条件为ture
+                Expression result = Expression.Constant(true);
+                foreach (var filter in filters)
+                {
+                    result = result.AndAlso(param.GenerateBody<T>(filter));
+
+                }
+
+                query = query.Where(param.GenerateTypeLambda<T>(result));
+            }
+            return query;
+        }
+    }
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2336 - 0
TEAMModelOS.Helper.Query/LinqHelper/DynamicQueryable.cs


+ 13 - 0
TEAMModelOS.Helper.Query/LinqHelper/Filter.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Query.LinqHelper
+{
+    public class Filter
+    {
+        public string Key { get; set; }
+        public string Value { get; set; }
+        public string Contrast { get; set; }
+    }
+}

+ 7 - 0
TEAMModelOS.Helper.Query/TEAMModelOS.Helper.Query.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 218 - 0
TEAMModelOS.Helper.Security/AESCrypt/AESCrypt.cs


+ 29 - 0
TEAMModelOS.Helper.Security/BCryptHelper/BCryptHelper.cs

@@ -0,0 +1,29 @@
+
+namespace TEAMModelOS.Helper.Security.BCryptHelper
+{
+    /// <summary>
+    /// BCrypt散列加密算法
+    /// </summary>
+    public class BCryptHelper
+    {
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="code"></param>
+        /// <returns></returns>
+        public static string Ecrypt(string code)
+        {
+            return BCrypt.Net.BCrypt.EnhancedHashPassword(code);
+        }
+        /// <summary>
+        /// 验证
+        /// </summary>
+        /// <param name="code"></param>
+        /// <param name="encode"></param>
+        /// <returns></returns>
+        public static bool Verify(string code, string encode)
+        {
+            return BCrypt.Net.BCrypt.EnhancedVerify(code, encode);
+        }
+    }
+}

+ 69 - 0
TEAMModelOS.Helper.Security/Base64Crypt/Base64Crypt.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Security.Base64Crypt
+{
+    public static class Base64Crypt
+    {
+        /// <summary>
+        /// Base64加密
+        /// </summary>
+        /// <param name="codeName">加密采用的编码方式</param>
+        /// <param name="source">待加密的明文</param>
+        /// <returns></returns>
+        public static string EncodeBase64(Encoding encode, string source)
+        {
+            byte[] bytes = encode.GetBytes(source);
+            try
+            {
+                source = Convert.ToBase64String(bytes);
+            }
+            catch (System.Exception e)
+            {
+                String s = e.StackTrace;
+            }
+            return source;
+        }
+
+        /// <summary>
+        /// Base64加密,采用utf8编码方式加密
+        /// </summary>
+        /// <param name="source">待加密的明文</param>
+        /// <returns>加密后的字符串</returns>
+        public static string EncodeBase64(string source)
+        {
+            return EncodeBase64(Encoding.UTF8, source);
+        }
+
+        /// <summary>
+        /// Base64解密
+        /// </summary>
+        /// <param name="codeName">解密采用的编码方式,注意和加密时采用的方式一致</param>
+        /// <param name="result">待解密的密文</param>
+        /// <returns>解密后的字符串</returns>
+        public static string DecodeBase64(Encoding encode, string result)
+        {
+            string decode = "";
+            byte[] bytes = Convert.FromBase64String(result);
+            try
+            {
+                decode = encode.GetString(bytes);
+            }
+            catch
+            {
+                decode = result;
+            }
+            return decode;
+        }
+
+        /// <summary>
+        /// Base64解密,采用utf8编码方式解密
+        /// </summary>
+        /// <param name="result">待解密的密文</param>
+        /// <returns>解密后的字符串</returns>
+        public static string DecodeBase64(string result)
+        {
+            return DecodeBase64(Encoding.UTF8, result);
+        }
+    }
+}

+ 133 - 0
TEAMModelOS.Helper.Security/DesCrypt/DES3Crypt.cs

@@ -0,0 +1,133 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Security.DesCrypt
+{
+    /// <summary>
+    ///3DES加密解密程序
+    /// --备用
+    /// </summary>
+    public class DES3Crypt
+    {
+        //密钥
+
+        private static string sKey = "qJzGEh6hESZDVJeCnFPGuxzaiFYTLQM3";
+
+        //矢量,矢量可以为空
+
+        private static string sIV = "qcDY6X+aPLw=";
+
+        //构造一个对称算法
+
+        private static SymmetricAlgorithm mCSP = new TripleDESCryptoServiceProvider();
+
+
+
+        public DES3Crypt() { }
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="Value">明文</param>
+        /// <returns>加密后的密文</returns>
+        public static string EncryptString(string Value)
+        {
+            try
+            {
+
+                ICryptoTransform ct;
+
+                MemoryStream ms;
+
+                CryptoStream cs;
+
+                byte[] byt;
+
+                mCSP.Key = Convert.FromBase64String(sKey);
+
+                mCSP.IV = Convert.FromBase64String(sIV);
+
+                //指定加密的运算模式
+
+                mCSP.Mode = System.Security.Cryptography.CipherMode.ECB;
+
+                //获取或设置加密算法的填充模式
+
+                mCSP.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
+
+                ct = mCSP.CreateEncryptor(mCSP.Key, mCSP.IV);
+
+                byt = Encoding.UTF8.GetBytes(Value + "_0212YUAN");
+
+                ms = new MemoryStream();
+
+                cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
+
+                cs.Write(byt, 0, byt.Length);
+
+                cs.FlushFinalBlock();
+
+                cs.Close();
+
+                return Convert.ToBase64String(ms.ToArray());
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+                return Value;
+            }
+
+        }
+
+        /// <summary>
+        /// 解密
+        /// </summary>
+        /// <param name="Value"></param>
+        /// <returns></returns>
+        public static string DecryptString(string Value)
+        {
+            try
+            {
+
+                ICryptoTransform ct;
+
+                MemoryStream ms;
+
+                CryptoStream cs;
+
+                byte[] byt;
+
+                mCSP.Key = Convert.FromBase64String(sKey);
+
+                mCSP.IV = Convert.FromBase64String(sIV);
+
+                mCSP.Mode = System.Security.Cryptography.CipherMode.ECB;
+
+                mCSP.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
+
+                ct = mCSP.CreateDecryptor(mCSP.Key, mCSP.IV);
+
+                byt = Convert.FromBase64String(Value);
+
+                ms = new MemoryStream();
+
+                cs = new CryptoStream(ms, ct, CryptoStreamMode.Write);
+
+                cs.Write(byt, 0, byt.Length);
+
+                cs.FlushFinalBlock();
+
+                cs.Close();
+
+                return Encoding.UTF8.GetString(ms.ToArray()).Remove(Encoding.UTF8.GetString(ms.ToArray()).Length - 9, 9);
+            }
+            catch (Exception ex)
+            {
+                var s = ex.Message;
+                return Value;
+            }
+        }
+    }
+}

+ 97 - 0
TEAMModelOS.Helper.Security/DesCrypt/DESCrypt.cs

@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+using TEAMModelOS.Helper.Common.StringHelper;
+
+namespace TEAMModelOS.Helper.Security.DesCrypt
+{
+    public class DESCrypt
+    {
+        #region  ========算法========
+        private static string key;//密钥
+        static DESCrypt()
+        {
+            key = "HaBook.TeamModel.SDK";
+        }
+        private static byte[] Keys = new byte[] { 0x12, 0x34, 0x56, 120, 0x90, 0xab, 0xcd, 0xef };//8个bit位,是DES算法的初始化向量  加解密钥也是8位;
+        /// <summary>
+        /// 解密字符串
+        /// </summary>
+        /// <param name="decryptString">是要被解密的密文数据</param>
+        /// <param name="decryptKey">DES算法的工作密钥</param>
+        /// <returns>明文</returns>
+        public static string Decrypt(string decryptString, string decryptKey)
+        {
+            try
+            {
+                decryptKey = StringHelper.GetSubString(decryptKey, 8, "");
+                decryptKey = decryptKey.PadRight(8, ' ');
+                byte[] bytes = Encoding.UTF8.GetBytes(decryptKey);
+                byte[] keys = Keys;
+                byte[] buffer = Convert.FromBase64String(decryptString);
+                DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
+                MemoryStream stream = new MemoryStream();
+                CryptoStream stream2 = new CryptoStream(stream, provider.CreateDecryptor(bytes, keys), CryptoStreamMode.Write);
+                stream2.Write(buffer, 0, buffer.Length);
+                stream2.FlushFinalBlock();
+                return Encoding.UTF8.GetString(stream.ToArray());
+            }
+            catch
+            {
+                return "";
+            }
+        }
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="decryptString">要被加密数据</param>
+        /// <param name="decryptKey">DES算法的工作密钥</param>
+        /// <returns>密文</returns>
+        public static string Encrypt(string encryptString, string encryptKey)
+        {
+            encryptKey = StringHelper.GetSubString(encryptKey, 8, "");
+            encryptKey = encryptKey.PadRight(8, ' ');
+            byte[] bytes = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
+            byte[] keys = Keys;
+            byte[] buffer = Encoding.UTF8.GetBytes(encryptString);
+            DESCryptoServiceProvider provider = new DESCryptoServiceProvider();
+            MemoryStream stream = new MemoryStream();
+            CryptoStream stream2 = new CryptoStream(stream, provider.CreateEncryptor(bytes, keys), CryptoStreamMode.Write);
+            stream2.Write(buffer, 0, buffer.Length);
+            stream2.FlushFinalBlock();
+            return Convert.ToBase64String(stream.ToArray());//Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,Base64要求把每三个8Bit的字节转换为四个6Bit的字节(3*8 = 4*6 = 24),然后把6Bit再添两位高位0,组成四个8Bit的字节。
+            //Base64编码可用于在HTTP环境下传递较长的标识信息,如较长的唯一标识符(一般为128-bit的UUID)编码为一个字符串,用作HTTP表单和HTTP GET URL中的参数,或者将二进制数据编码为适合放在URL(包括隐藏表单域)中的形式。此时,采用Base64编码不仅比较简短,同时也具有不可读性,即所编码的数据不会被人用肉眼所直接看到。
+        }
+        #endregion
+
+        #region ========加密========
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="Text"></param>
+        /// <returns></returns>
+        public static string Encrypt(string Text)
+        {
+            return Encrypt(Text, key);
+        }
+        #endregion
+
+        #region ========解密========
+
+        /// <summary>
+        /// 解密
+        /// </summary>
+        /// <param name="Text"></param>
+        /// <returns></returns>
+        public static string Decrypt(string Text)
+        {
+            return Decrypt(Text, key);
+        }
+        #endregion
+
+    }
+}

+ 87 - 0
TEAMModelOS.Helper.Security/Md5Hash/Md5Hash.cs

@@ -0,0 +1,87 @@
+using System;
+using System.IO;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace TEAMModelOS.Helper.Security.Md5Hash
+{
+    public  class Md5Hash
+    {
+        #region MD5加密字符串处理
+        /// <summary>
+        /// MD5加密字符串处理
+        /// </summary>
+        /// <param name="half">加密是16位还是32位;如果为true为16位</param>
+        /// <param name="input">待加密码字符串</param>
+        /// <returns></returns>
+        public static string Encrypt(string input, bool half)
+        {
+            using (var md5 = MD5.Create())
+            {
+                var result = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
+                var strResult = BitConverter.ToString(result);
+                strResult = strResult.Replace("-", "");
+                if (half)//16位MD5加密(取32位加密的9~25字符)
+                {
+                    strResult = strResult?.Substring(8, 16);
+                }
+                return strResult;
+            }
+        }
+        #endregion
+
+        /// <summary>
+        /// MD5加密
+        /// </summary>
+        /// <param name="strPwd">加密的字符串</param>
+        /// <returns></returns>
+        public static string Encrypt(string strPwd)
+        {
+            MD5 md5 = new MD5CryptoServiceProvider();
+            byte[] data = System.Text.Encoding.Default.GetBytes(strPwd);
+            byte[] result = md5.ComputeHash(data);
+            string ret = "";
+            for (int i = 0; i < result.Length; i++)
+                ret += result[i].ToString("x").PadLeft(2, '0');
+            return ret;
+        }
+
+        public static string GetMd5String(string str)
+        {
+            MD5 md5 = MD5.Create();
+            byte[] data = Encoding.UTF8.GetBytes(str);
+            byte[] enData = md5.ComputeHash(data);
+            return GetbyteToString(enData);
+        }
+
+        public static string GetMD5String(string str, HashAlgorithm hash)
+        {
+
+            byte[] data = Encoding.UTF8.GetBytes(str);
+            byte[] data2 = hash.ComputeHash(data);
+            return GetbyteToString(data2);
+        }
+
+        public static string GetMD5FromFile(string path)
+        {
+            MD5 md5 = MD5.Create();
+            if (!File.Exists(path))
+            {
+                return "";
+            }
+            FileStream stream = File.OpenRead(path);
+            byte[] data2 = md5.ComputeHash(stream);
+            return GetbyteToString(data2);
+            //return BitConverter.ToString(data2).Replace("-", "").ToLower();
+        }
+        private static string GetbyteToString(byte[] data)
+        {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < data.Length; i++)
+            {
+                sb.Append(data[i].ToString("x2"));
+            }
+            return sb.ToString();
+        }
+    }
+}

+ 62 - 0
TEAMModelOS.Helper.Security/RSACrypt/RSACrypt.cs

@@ -0,0 +1,62 @@
+using System.Collections.Generic;
+using System.Security.Cryptography;
+using System.Text;
+using XC.Framework.Security.RSAUtil;
+
+namespace TEAMModelOS.Helper.Security.RSACrypt
+{
+    /// <summary>
+    /// RSA加密解密
+    /// https://github.com/stulzq/RSAUtil
+    /// </summary>
+    public class RSACrypt
+    {
+
+        private readonly RsaPkcs1Util _RsaUtil;
+        private readonly Encoding _encoding;
+
+        /// <summary>
+        /// 获得私钥和公钥
+        /// [0]=privateKey  私钥 
+        /// [1]=publicKey  公钥
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> GetKey()
+        {
+            return RsaKeyGenerator.Pkcs1Key(2048, true);
+        }
+
+        /// <summary>
+        /// 实例化
+        /// </summary>
+        /// <param name="encoding">编码类型</param>
+        /// <param name="privateKey">私钥</param>
+        /// <param name="publicKey">公钥</param>
+        public RSACrypt(string privateKey, string publicKey)
+        {
+            _encoding = Encoding.UTF8;
+            _RsaUtil = new RsaPkcs1Util(_encoding, publicKey, privateKey, 1024);
+        }
+
+        /// <summary>
+        /// 加密
+        /// </summary>
+        /// <param name="code">加密代码</param>
+        /// <returns></returns>
+        public string Encrypt(string code)
+        {
+            return _RsaUtil.Encrypt(code, RSAEncryptionPadding.Pkcs1);
+        }
+
+        /// <summary>
+        /// 解密
+        /// </summary>
+        /// <param name="code">解密代码</param>
+        /// <returns></returns>
+        public string Decrypt(string code)
+        {
+            return _RsaUtil.Decrypt(code, RSAEncryptionPadding.Pkcs1);
+        }
+
+    }
+}

+ 16 - 0
TEAMModelOS.Helper.Security/TEAMModelOS.Helper.Security.csproj

@@ -0,0 +1,16 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="BCrypt.Net-Next" Version="3.1.3" />
+    <PackageReference Include="XC.Framework.Security.RSAUtil" Version="1.0.1" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\TEAMModelOS.Helper.Common\TEAMModelOS.Helper.Common.csproj" />
+  </ItemGroup>
+
+</Project>

+ 1 - 0
TEAMModelOS.Model.Analysis/README.md

@@ -0,0 +1 @@
+ر�اى�ضخ�ؤ�ذح

+ 7 - 0
TEAMModelOS.Model.Analysis/TEAMModelOS.Model.Analysis.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 0 - 0
TEAMModelOS.Model.Common/README.md


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov