liyuanyuan 10 months ago
parent
commit
d8bca22f82
46 changed files with 0 additions and 3806 deletions
  1. 0 174
      MadRunFabric.ThirdPartyApi/Controllers/SmsController.cs
  2. 0 25
      MadRunFabric.ThirdPartyApi/Controllers/info/InfoController.cs
  3. 0 28
      MadRunFabric.ThirdPartyApi/Program.cs
  4. 0 38
      MadRunFabric.ThirdPartyApi/Properties/launchSettings.json
  5. 0 177
      MadRunFabric.ThirdPartyApi/Startup.cs
  6. 0 38
      MadRunFabric.ThirdPartyApi/ThirdPartyApi.csproj
  7. 0 62
      MadRunFabric.ThirdPartyApi/appsettings.Development.json
  8. 0 63
      MadRunFabric.ThirdPartyApi/appsettings.Production.json
  9. 0 15
      MadRunFabric.ThirdPartyApi/appsettings.json
  10. 0 71
      MadRunFabric.ThirdPartyApi/nlog.config
  11. 0 51
      MadRunFabric.WechatApi/WechatApi.IRepositories/ICall_RecordsRepository.cs
  12. 0 13
      MadRunFabric.WechatApi/WechatApi.IRepositories/ILocationRepository.cs
  13. 0 12
      MadRunFabric.WechatApi/WechatApi.IRepositories/ISys_User_AccountRepository.cs
  14. 0 13
      MadRunFabric.WechatApi/WechatApi.IRepositories/WechatApi.IRepositories.csproj
  15. 0 11
      MadRunFabric.WechatApi/WechatApi.Model/WechatApi.Model.csproj
  16. 0 456
      MadRunFabric.WechatApi/WechatApi.Repositories/Call_RecordsRepository.cs
  17. 0 21
      MadRunFabric.WechatApi/WechatApi.Repositories/LocationRepository.cs
  18. 0 21
      MadRunFabric.WechatApi/WechatApi.Repositories/Sys_User_AccountRepository.cs
  19. 0 12
      MadRunFabric.WechatApi/WechatApi.Repositories/WechatApi.Repositories.csproj
  20. 0 113
      MadRunFabric.WechatApi/WechatApi/Controllers/HomeController.cs
  21. 0 26
      MadRunFabric.WechatApi/WechatApi/Controllers/Info/InfoController.cs
  22. 0 155
      MadRunFabric.WechatApi/WechatApi/Controllers/LocationController.cs
  23. 0 107
      MadRunFabric.WechatApi/WechatApi/Controllers/LoginController.cs
  24. 0 145
      MadRunFabric.WechatApi/WechatApi/Controllers/MenuController.cs
  25. 0 114
      MadRunFabric.WechatApi/WechatApi/Controllers/PaymentController.cs
  26. 0 77
      MadRunFabric.WechatApi/WechatApi/Controllers/SendMessageController.cs
  27. 0 122
      MadRunFabric.WechatApi/WechatApi/Controllers/TemplateMessageController.cs
  28. 0 100
      MadRunFabric.WechatApi/WechatApi/Controllers/ValuesController.cs
  29. 0 183
      MadRunFabric.WechatApi/WechatApi/Controllers/traffic/AnalysisController.cs
  30. 0 232
      MadRunFabric.WechatApi/WechatApi/CryptCode/Cryptography.cs
  31. 0 221
      MadRunFabric.WechatApi/WechatApi/CryptCode/WXBizMsgCrypt.cs
  32. 0 111
      MadRunFabric.WechatApi/WechatApi/MessageHanders/CustomMessageHandler.cs
  33. 0 19
      MadRunFabric.WechatApi/WechatApi/Model/LocationInput.cs
  34. 0 17
      MadRunFabric.WechatApi/WechatApi/Model/MenuInput.cs
  35. 0 15
      MadRunFabric.WechatApi/WechatApi/Model/TemplateSendDto.cs
  36. 0 13
      MadRunFabric.WechatApi/WechatApi/Model/WorkOrderInput.cs
  37. 0 32
      MadRunFabric.WechatApi/WechatApi/Program.cs
  38. 0 47
      MadRunFabric.WechatApi/WechatApi/Properties/launchSettings.json
  39. 0 213
      MadRunFabric.WechatApi/WechatApi/Startup.cs
  40. 0 40
      MadRunFabric.WechatApi/WechatApi/WechatApi.csproj
  41. 0 79
      MadRunFabric.WechatApi/WechatApi/appsettings.Development.json
  42. 0 79
      MadRunFabric.WechatApi/WechatApi/appsettings.Development_Base.json
  43. 0 79
      MadRunFabric.WechatApi/WechatApi/appsettings.Development_Test.json
  44. 0 80
      MadRunFabric.WechatApi/WechatApi/appsettings.Production.json
  45. 0 15
      MadRunFabric.WechatApi/WechatApi/appsettings.json
  46. 0 71
      MadRunFabric.WechatApi/WechatApi/nlog.config

+ 0 - 174
MadRunFabric.ThirdPartyApi/Controllers/SmsController.cs

@@ -1,174 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using Aliyun.Acs.Core;
6
-using Aliyun.Acs.Core.Exceptions;
7
-using Aliyun.Acs.Core.Profile;
8
-using Aliyun.Acs.Dysmsapi.Model.V20170525;
9
-using Api.SignToken;
10
-using AutoMapper;
11
-using MadRunFabric.Common;
12
-using Microsoft.AspNetCore.Authorization;
13
-using Microsoft.AspNetCore.Mvc;
14
-using Microsoft.Extensions.Configuration;
15
-using Microsoft.Extensions.Logging;
16
-
17
-namespace ThirdPartyApi.Controllers
18
-{
19
-    //[Authorize]
20
-    [ApiVersion("6.0")]
21
-    [Produces("application/json")]
22
-    [Route("api/[controller]")]
23
-    public class SmsController : BaseController
24
-    {
25
-        private readonly ILogger<SmsController> _logger;
26
-        private readonly ISignTokenService _signTokenService;
27
-        private readonly IConfiguration _configuration;
28
-        private readonly IMapper _mapper;
29
-
30
-        public SmsController(ILogger<SmsController> logger, ISignTokenService signTokenService, IConfiguration configuration, IMapper mapper)
31
-        {
32
-            _logger = logger;
33
-            _signTokenService = signTokenService;
34
-            _configuration = configuration;
35
-            _mapper = mapper;
36
-        }
37
-
38
-        /// <summary>
39
-        /// 发送短信
40
-        /// </summary>
41
-        /// <param name="signname">签名</param>
42
-        /// <param name="templatecode">模板代码</param>
43
-        /// <param name="phonenumber">手机号码</param>
44
-        /// <param name="json">模板参数赋值json</param>
45
-        /// <returns></returns>
46
-        [HttpPost("sendsms")]
47
-        public IActionResult SendSms(string signname, string templatecode, string phonenumber, string json)
48
-        {
49
-            //string json = "{\"name\":\"张三\",\"code\":\"ZS-123456\"}";
50
-
51
-            string product = _configuration["Dysms:product"];
52
-            string domain = _configuration["Dysms:domain"];
53
-            string accesskeyid = _configuration["Dysms:accesskeyid"];
54
-            string accesskeysecret = _configuration["Dysms:accesskeysecret"];
55
-
56
-            IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accesskeyid, accesskeysecret);
57
-            DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
58
-            IAcsClient acsClient = new DefaultAcsClient(profile);
59
-            SendSmsRequest request = new SendSmsRequest();
60
-            SendSmsResponse response = null;
61
-            try
62
-            {
63
-
64
-                //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
65
-                request.PhoneNumbers = phonenumber;
66
-                //必填:短信签名-可在短信控制台中找到
67
-                request.SignName = signname;
68
-                //必填:短信模板-可在短信控制台中找到
69
-                request.TemplateCode = templatecode;
70
-                //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
71
-                request.TemplateParam = json;
72
-                //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
73
-                //request.OutId = "yourOutId";
74
-                //请求失败这里会抛ClientException异常
75
-                response = acsClient.GetAcsResponse(request);
76
-
77
-            }
78
-            catch (ServerException e)
79
-            {
80
-                _logger.LogError("发送短信异常1,原因:" + e.ToString());
81
-            }
82
-            catch (ClientException e)
83
-            {
84
-                _logger.LogError("发送短信异常2,原因:" + e.ToString());
85
-            }
86
-            if (response != null)
87
-            {
88
-                if (response.Code != "OK")
89
-                {
90
-                    return Error(response.Message);
91
-                }
92
-            }
93
-            else
94
-            {
95
-                return Error("失败");
96
-            }
97
-            return Success("成功", phonenumber);
98
-        }
99
-
100
-        /// <summary>
101
-        /// 获取发送短信列表
102
-        /// </summary>
103
-        /// <param name="bizid">流水号</param>
104
-        /// <param name="phonenumber">号码</param>
105
-        /// <param name="senddate">发送日期</param>
106
-        /// <param name="pagesize">页大小</param>
107
-        /// <param name="pageindex">当前页码</param>
108
-        /// <returns></returns>
109
-        [HttpGet("getlistbypage")]
110
-        public IActionResult GetListByPage(string bizid, string phonenumber, string senddate, long? pagesize = 10, long? pageindex = 1)
111
-        {
112
-            string product = _configuration["Dysms:product"];
113
-            string domain = _configuration["Dysms:domain"];
114
-            string accesskeyid = _configuration["Dysms:accesskeyid"];
115
-            string accesskeysecret = _configuration["Dysms:accesskeysecret"];
116
-
117
-            //初始化acsClient,暂不支持region化
118
-            IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accesskeyid, accesskeysecret);
119
-            DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
120
-            IAcsClient acsClient = new DefaultAcsClient(profile);
121
-            //组装请求对象
122
-            QuerySendDetailsRequest request = new QuerySendDetailsRequest();
123
-            //必填-号码
124
-            request.PhoneNumber = phonenumber;
125
-            //可选-流水号
126
-            request.BizId = bizid;
127
-            if (string.IsNullOrEmpty(senddate))
128
-            {
129
-                senddate = DateTime.Now.ToString("yyyyMMdd");
130
-            }
131
-            //必填-发送日期 支持30天内记录查询,格式yyyyMMdd       
132
-            request.SendDate = senddate;
133
-            //必填-页大小
134
-            request.PageSize = pagesize;
135
-            //必填-当前页码从1开始计数
136
-            request.CurrentPage = pageindex;
137
-
138
-            QuerySendDetailsResponse querySendDetailsResponse = null;
139
-            try
140
-            {
141
-                querySendDetailsResponse = acsClient.GetAcsResponse(request);
142
-            }
143
-            catch (ServerException e)
144
-            {
145
-                _logger.LogError("查询短信异常1,原因:" + e.ToString());
146
-            }
147
-            catch (ClientException e)
148
-            {
149
-                _logger.LogError("查询短信异常2,原因:" + e.ToString());
150
-            }
151
-
152
-            if (querySendDetailsResponse != null)
153
-            {
154
-                if (querySendDetailsResponse.Code != "OK")
155
-                {
156
-                    return Error(querySendDetailsResponse.Message);
157
-                }
158
-                else
159
-                {
160
-                    var obj = new
161
-                    {
162
-                        rows = querySendDetailsResponse.SmsSendDetailDTOs,
163
-                        total = querySendDetailsResponse.TotalCount
164
-                    };
165
-                    return Success("获取成功", obj);
166
-                }
167
-            }
168
-            else
169
-            {
170
-                return Error("失败");
171
-            }
172
-        }
173
-    }
174
-}

+ 0 - 25
MadRunFabric.ThirdPartyApi/Controllers/info/InfoController.cs

@@ -1,25 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using MadRunFabric.Common;
6
-using Microsoft.AspNetCore.Authorization;
7
-using Microsoft.AspNetCore.Mvc;
8
-
9
-namespace ThirdPartyApi.Controllers.info
10
-{
11
-    [ApiVersion("6.0")]
12
-    [AllowAnonymous]
13
-    [Produces("application/json")]
14
-    [Route("api/Info")]
15
-    public class InfoController : BaseController
16
-    {
17
-        [HttpGet]
18
-        public IEnumerable<string> Get()
19
-        {
20
-            return new string[] { $"版本信息 {RequestedApiVersion}", "开发团队: Mad Fun Fabric", Request.Headers.ToJson() };
21
-        }
22
-
23
-        protected ApiVersion RequestedApiVersion => HttpContext.GetRequestedApiVersion();
24
-    }
25
-}

+ 0 - 28
MadRunFabric.ThirdPartyApi/Program.cs

@@ -1,28 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.IO;
4
-using System.Linq;
5
-using System.Threading.Tasks;
6
-using Microsoft.AspNetCore;
7
-using Microsoft.AspNetCore.Hosting;
8
-using Microsoft.Extensions.Configuration;
9
-using Microsoft.Extensions.Logging;
10
-using NLog.Extensions.Logging;
11
-using NLog.Web;
12
-
13
-namespace ThirdPartyApi
14
-{
15
-    public class Program
16
-    {
17
-        public static void Main(string[] args)
18
-        {
19
-            BuildWebHost(args).Run();
20
-        }
21
-
22
-        public static IWebHost BuildWebHost(string[] args) =>
23
-            WebHost.CreateDefaultBuilder(args)
24
-                .UseStartup<Startup>()
25
-                .UseUrls("http://*:28320")
26
-                .Build();
27
-    }
28
-}

+ 0 - 38
MadRunFabric.ThirdPartyApi/Properties/launchSettings.json

@@ -1,38 +0,0 @@
1
-{
2
-  "iisSettings": {
3
-    "windowsAuthentication": false,
4
-    "anonymousAuthentication": true,
5
-    "iisExpress": {
6
-      "applicationUrl": "http://localhost:28320/",
7
-      "sslPort": 0
8
-    }
9
-  },
10
-  "profiles": {
11
-    "IIS Express": {
12
-      "commandName": "IISExpress",
13
-      "launchBrowser": true,
14
-      "launchUrl": "api/info",
15
-      "environmentVariables": {
16
-        "ASPNETCORE_ENVIRONMENT": "Development"
17
-      }
18
-    },
19
-    "ThirdPartyApi(Dev)": {
20
-      "commandName": "Project",
21
-      "launchBrowser": true,
22
-      "launchUrl": "api/info",
23
-      "environmentVariables": {
24
-        "ASPNETCORE_ENVIRONMENT": "Development"
25
-      },
26
-      "applicationUrl": "http://localhost:28320/"
27
-    },
28
-    "ThirdPartyApi(Prod)": {
29
-      "commandName": "Project",
30
-      "launchBrowser": true,
31
-      "launchUrl": "api/info",
32
-      "environmentVariables": {
33
-        "ASPNETCORE_ENVIRONMENT": "Production"
34
-      },
35
-      "applicationUrl": "http://localhost:28320/"
36
-    }
37
-  }
38
-}

+ 0 - 177
MadRunFabric.ThirdPartyApi/Startup.cs

@@ -1,177 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.IdentityModel.Tokens.Jwt;
4
-using System.Linq;
5
-using System.Text;
6
-using System.Threading.Tasks;
7
-using Api.SignToken;
8
-using MadRunFabric.Common;
9
-using Microsoft.AspNetCore.Authentication.JwtBearer;
10
-using Microsoft.AspNetCore.Authorization;
11
-using Microsoft.AspNetCore.Builder;
12
-using Microsoft.AspNetCore.Hosting;
13
-using Microsoft.AspNetCore.Mvc.Versioning;
14
-using Microsoft.Extensions.Configuration;
15
-using Microsoft.Extensions.DependencyInjection;
16
-using Microsoft.Extensions.Logging;
17
-using Microsoft.Extensions.Options;
18
-using Microsoft.IdentityModel.Tokens;
19
-using Pivotal.Discovery.Client;
20
-using AutoMapper;
21
-using NLog.Extensions.Logging;
22
-using NLog.Web;
23
-
24
-namespace ThirdPartyApi
25
-{
26
-    public class Startup
27
-    {
28
-        public Startup(IHostingEnvironment env)
29
-        {
30
-            Configuration = new ConfigurationBuilder()
31
-                           .SetBasePath(env.ContentRootPath)
32
-                           .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
33
-                           .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
34
-                           .AddEnvironmentVariables()
35
-                           .Build();
36
-        }
37
-
38
-        public IConfiguration Configuration { get; }
39
-
40
-        // This method gets called by the runtime. Use this method to add services to the container.
41
-        public void ConfigureServices(IServiceCollection services)
42
-        {
43
-            #region Cors 配置
44
-            //生产环境 的cors
45
-            services.AddCors(options =>
46
-            {
47
-                options.AddPolicy("CorsProd",
48
-                builder => builder.AllowAnyOrigin()
49
-                //builder => builder.WithOrigins(Configuration["Cors"].Split(','))
50
-                .AllowAnyMethod()
51
-                .AllowAnyHeader()
52
-                .AllowCredentials().SetPreflightMaxAge(TimeSpan.FromMinutes(30)));
53
-            });
54
-            //开发环境的cors
55
-            services.AddCors(options =>
56
-            {
57
-                options.AddPolicy("CorsDev",
58
-                builder => builder.AllowAnyOrigin()
59
-                .AllowAnyMethod()
60
-                .AllowAnyHeader()
61
-                .AllowCredentials().SetPreflightMaxAge(TimeSpan.FromMinutes(30)));
62
-            });
63
-            #endregion
64
-
65
-            #region 授权配置
66
-            //读取jwt配置文件
67
-            var signingKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:SecretKey"].ToString()));
68
-            var tokenValidationParameters = new TokenValidationParameters
69
-            {
70
-                ValidateIssuerSigningKey = true,
71
-                IssuerSigningKey = signingKey,
72
-                ValidateIssuer = true,
73
-                ValidIssuer = Configuration["Jwt:Issuer"].ToString(),//发行人
74
-                ValidateAudience = true,
75
-                ValidAudience = Configuration["Jwt:Audience"].ToString(),//订阅人
76
-                ValidateLifetime = true,
77
-                ClockSkew = TimeSpan.Zero,
78
-                RequireExpirationTime = true,
79
-            };
80
-
81
-            services.AddAuthentication(options =>
82
-            {
83
-                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
84
-                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
85
-            })
86
-            .AddJwtBearer(o =>
87
-            {
88
-                o.RequireHttpsMetadata = false;
89
-                o.TokenValidationParameters = tokenValidationParameters;
90
-                o.Events = new JwtBearerEvents
91
-                {
92
-                    OnTokenValidated = context =>
93
-                    {
94
-                        if (context.Request.Path.Value.ToString() == "/api/logout")
95
-                        {
96
-                            var token = ((context as TokenValidatedContext).SecurityToken as JwtSecurityToken).RawData;
97
-                        }
98
-                        return Task.CompletedTask;
99
-                    }
100
-                };
101
-            });
102
-            #endregion
103
-
104
-            #region redis配置
105
-            services.AddDistributedRedisCache(options =>
106
-            {
107
-                options.InstanceName = Configuration["Redis:InstanceName"].ToString();
108
-                options.Configuration = $"{Configuration["Redis:HostName"].ToString()}:{Configuration["Redis:Port"].ToString()},allowAdmin=true,password={Configuration["Redis:Password"].ToString()},defaultdatabase={Configuration["Redis:Defaultdatabase"].ToString()}";
109
-            });
110
-            #endregion
111
-
112
-            services.AddSingleton<IConfiguration>(Configuration);
113
-
114
-            //注入授权Handler
115
-            services.AddSingleton<IAuthorizationHandler, PermissionAuthorizationHandler>();
116
-            services.AddSingleton<IPermissionService, PermissionService>();
117
-            services.AddSingleton<ISignTokenService, SignTokenService>();
118
-
119
-            #region 版本控制
120
-            services.AddApiVersioning(Options =>
121
-            {
122
-                Options.ReportApiVersions = true;//可选,为true API返回响应标头中支持的版本信息
123
-                Options.ApiVersionReader = new QueryStringApiVersionReader(parameterName: "api-version");
124
-                Options.AssumeDefaultVersionWhenUnspecified = true;
125
-                Options.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(6, 0);
126
-            });
127
-            #endregion
128
-
129
-
130
-            #region AutoMapper
131
-            services.AddAutoMapper();
132
-            #endregion
133
-
134
-            services.AddMvc(options =>
135
-            {
136
-                options.Filters.Add<ActionFilter>();
137
-                options.Filters.Add(new ExceptionFilter());
138
-            }).AddJsonOptions(op => op.SerializerSettings.ContractResolver =
139
-                                        new Newtonsoft.Json.Serialization.DefaultContractResolver());
140
-
141
-
142
-            #region steeltoe
143
-            services.AddDiscoveryClient(Configuration);
144
-            #endregion
145
-        }
146
-
147
-        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
148
-        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
149
-        {
150
-            if (env.IsProduction())
151
-            {
152
-                app.UseCors("CorsProd");
153
-            }
154
-            else
155
-            {
156
-                app.UseCors("CorsDev");
157
-                app.UseDeveloperExceptionPage();
158
-                app.UseDatabaseErrorPage();
159
-                app.UseBrowserLink();
160
-            }
161
-
162
-            app.UseAuthentication();
163
-
164
-            app.UseMvc();
165
-
166
-            #region steeltoe
167
-            app.UseDiscoveryClient();
168
-            #endregion
169
-
170
-            #region Nlog 引入
171
-            loggerFactory.AddNLog();//添加NLog
172
-            env.ConfigureNLog("nlog.config");//读取Nlog配置文件
173
-            app.AddNLogWeb();
174
-            #endregion
175
-        }
176
-    }
177
-}

+ 0 - 38
MadRunFabric.ThirdPartyApi/ThirdPartyApi.csproj

@@ -1,38 +0,0 @@
1
-<Project Sdk="Microsoft.NET.Sdk.Web">
2
-
3
-  <PropertyGroup>
4
-    <TargetFramework>netcoreapp2.0</TargetFramework>
5
-  </PropertyGroup>
6
-
7
-  <ItemGroup>
8
-    <PackageReference Include="AutoMapper.Extensions" Version="1.1.0" />
9
-    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
10
-    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
11
-    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
12
-    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
13
-    <PackageReference Include="NLog.Web.AspNetCore" Version="4.4.1" />
14
-  </ItemGroup>
15
-
16
-  <ItemGroup>
17
-    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
18
-  </ItemGroup>
19
-
20
-  <ItemGroup>
21
-    <ProjectReference Include="..\Api.SignToken\Api.SignToken.csproj" />
22
-    <ProjectReference Include="..\MadRunFabric.Common\MadRunFabric.Common.csproj" />
23
-  </ItemGroup>
24
-
25
-  <ItemGroup>
26
-    <Folder Include="dll\" />
27
-  </ItemGroup>
28
-
29
-  <ItemGroup>
30
-    <Reference Include="aliyun-net-sdk-core">
31
-      <HintPath>dll\aliyun-net-sdk-core.dll</HintPath>
32
-    </Reference>
33
-    <Reference Include="aliyun-net-sdk-dysmsapi">
34
-      <HintPath>dll\aliyun-net-sdk-dysmsapi.dll</HintPath>
35
-    </Reference>
36
-  </ItemGroup>
37
-
38
-</Project>

+ 0 - 62
MadRunFabric.ThirdPartyApi/appsettings.Development.json

@@ -1,62 +0,0 @@
1
-{
2
-  "Cors": "",
3
-  "Logging": {
4
-    "IncludeScopes": false,
5
-    "LogLevel": {
6
-      "Default": "Debug",
7
-      "System": "Error",
8
-      "Microsoft": "Error",
9
-      "Steeltoe": "Error"
10
-    }
11
-  },
12
-  "Jwt": {
13
-    "Issuer": "HySignToken",
14
-    "Audience": "HyCallCenterApi",
15
-    "SecretKey": "HYBambooJIe256sdkDfjiTSkjienTGjnVcu85114udfhbudgdkfUh"
16
-  },
17
-  "MongoConnection": {
18
-    //"ConnectionString": "mongodb://root:123456@192.168.5.44:27017",
19
-    //"Database": "madrunfabricdb"
20
-    "ConnectionString": "mongodb://root:123456@192.168.5.44:27017", //本机
21
-    "Database": "yh"
22
-  },
23
-  "Redis": {
24
-    "HostName": "192.168.5.44",
25
-    "Port": "6379",
26
-    "Password": "",
27
-    "Defaultdatabase": "5",
28
-    "InstanceName": "test"
29
-  },
30
-  "spring": {
31
-    "application": {
32
-      "name": "thirdpartyapi"
33
-    }
34
-  },
35
-  "Dysms": {
36
-    "product": "Dysmsapi",
37
-    "domain": "dysmsapi.aliyuncs.com",
38
-    "accesskeyid": "LTAID8jj0g51ZsYv",
39
-    "accesskeysecret": "EH0S0XbUQihHSGA7FMutP0J8kzXqPk"
40
-  },
41
-  "eureka": {
42
-    "client": {
43
-      "serviceUrl": "http://192.168.5.46:28100/eureka/"
44
-      //"shouldFetchRegistry": false
45
-    },
46
-    "instance": {
47
-      "preferIpAddress": true,
48
-      //服务过期时间配置,
49
-      //超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除 #注意,EurekaServer一定要设置eureka.server.eviction-interval-timer-in-ms否则这个配置无效,这个配置一般为服务刷新时间配置的三倍
50
-      //默认90s 在删除实例之前,EurekaServer等待的时间,默认= 90秒
51
-      "leaseExpirationDurationInSeconds": 15,
52
-      //服务刷新时间配置,每隔这个时间会主动心跳一次
53
-      //默认30s 客户端需要发送心跳的频率,默认值= 30s
54
-      "leaseRenewalIntervalInSeconds": 5,
55
-      "statusPageUrlPath": "/api/info",
56
-      "port": 28320
57
-      // Remove comments to enable SSL requests
58
-      // More changes in Program.cs are required if using direct C2C communications
59
-      //,"securePortEnabled": true
60
-    }
61
-  }
62
-}

+ 0 - 63
MadRunFabric.ThirdPartyApi/appsettings.Production.json

@@ -1,63 +0,0 @@
1
-{
2
-  "Cors": "",
3
-  "Logging": {
4
-    "IncludeScopes": false,
5
-    "LogLevel": {
6
-      "Default": "Debug",
7
-      "System": "Error",
8
-      "Microsoft": "Error",
9
-      "Steeltoe": "Error"
10
-    }
11
-  },
12
-  "Jwt": {
13
-    "Issuer": "HySignToken",
14
-    "Audience": "HyCallCenterApi",
15
-    "SecretKey": "HYBambooJIe256sdkDfjiTSkjienTGjnVcu85114udfhbudgdkfUh"
16
-  },
17
-  "MongoConnection": {
18
-    //"ConnectionString": "mongodb://root:hykj800100@10.125.7.246:37017",
19
-    //"Database": "madrunfabricdb"
20
-    "ConnectionString": "mongodb://root:123456@192.168.5.44:27017", //本机
21
-    "Database": "yh"
22
-  },
23
-  "Redis": {
24
-    "HostName": "10.125.7.246",
25
-    "Port": "6379",
26
-    "Password": "hykj800100",
27
-    "Defaultdatabase": "5",
28
-    "InstanceName": "test"
29
-  },
30
-  "spring": {
31
-    "application": {
32
-      "name": "thirdpartyapi"
33
-    }
34
-  },
35
-  "Dysms": {
36
-    "product": "Dysmsapi",
37
-    "domain": "dysmsapi.aliyuncs.com",
38
-    "accesskeyid": "LTAID8jj0g51ZsYv",
39
-    "accesskeysecret": "EH0S0XbUQihHSGA7FMutP0J8kzXqPk"
40
-  },
41
-  "eureka": {
42
-    "client": {
43
-      //"serviceUrl": "http://localhost:4866/eureka/"
44
-      "serviceUrl": "http://10.125.3.223:28100/eureka/"
45
-      //"shouldFetchRegistry": false
46
-    },
47
-    "instance": {
48
-      "preferIpAddress": true,
49
-      //服务过期时间配置,
50
-      //超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除 #注意,EurekaServer一定要设置eureka.server.eviction-interval-timer-in-ms否则这个配置无效,这个配置一般为服务刷新时间配置的三倍
51
-      //默认90s 在删除实例之前,EurekaServer等待的时间,默认= 90秒
52
-      "leaseExpirationDurationInSeconds": 15,
53
-      //服务刷新时间配置,每隔这个时间会主动心跳一次
54
-      //默认30s 客户端需要发送心跳的频率,默认值= 30s
55
-      "leaseRenewalIntervalInSeconds": 5,
56
-      "statusPageUrlPath": "/api/info",
57
-      "port": 28320
58
-      // Remove comments to enable SSL requests
59
-      // More changes in Program.cs are required if using direct C2C communications
60
-      //,"securePortEnabled": true
61
-    }
62
-  }
63
-}

+ 0 - 15
MadRunFabric.ThirdPartyApi/appsettings.json

@@ -1,15 +0,0 @@
1
-{
2
-  "Logging": {
3
-    "IncludeScopes": false,
4
-    "Debug": {
5
-      "LogLevel": {
6
-        "Default": "Warning"
7
-      }
8
-    },
9
-    "Console": {
10
-      "LogLevel": {
11
-        "Default": "Warning"
12
-      }
13
-    }
14
-  }
15
-}

+ 0 - 71
MadRunFabric.ThirdPartyApi/nlog.config

@@ -1,71 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8" ?>
2
-<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
3
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-      autoReload="true"
5
-      internalLogLevel="Error"
6
-      internalLogFile="nlogtemp\internal-nlog.txt">
7
-
8
-  <!-- 加载ASP.NET Core插件 -->
9
-  <extensions>
10
-    <add assembly="NLog.Web.AspNetCore"/>
11
-  </extensions>
12
-
13
-  <!-- 输出目的地 -->
14
-  <targets>
15
-    <!-- 输出到文件,这个文件记录所有日志 -->
16
-    <!--<target xsi:type="File" name="allfile" fileName="\nlogtemp\${shortdate}\nlog-all-${shortdate}.log"
17
-                layout="记录时间:${longdate}|控制器:${logger}|消息:${message} 异常:${exception}" />-->
18
-
19
-    <!-- 另外一个日志记录文件,户口也跳过Microsoft开头相关日志信息 -->
20
-    <!--archiveFileName表示滚动日志存放路径,log.{#####}.txt是滚动日志文件名-->
21
-    <!--archiveAboveSize每个日志文件大小的最大值(单位:字节)20(mb)=20971520(b),主日志文件超过大小超过该值时会将文件内容写入滚动日志并清空主日志文件内容-->
22
-    <!--maxArchiveFiles滚动日志文件上限数,滚动日志文件数达到上限新的文件内容会覆盖旧文件内容 -->
23
-
24
-    <target xsi:type="File" name="own_file" fileName="log/${shortdate}/own_${shortdate}.log"
25
-            archiveFileName="log/${shortdate}/own_${shortdate}.{#####}.log"
26
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false" 
27
-            layout="${level}|记录时间:${longdate}|${event-properties:item=EventId.Id}|控制器:${logger}|action: ${aspnet-mvc-action}|${newline}消息:${message}|${newline}异常:${exception}|${newline}url: ${aspnet-request-url}|${newline}" />
28
-    <!--layout="记录时间:${longdate}|控制器:${logger}|  action: ${aspnet-mvc-action}|  消息:${message} 异常:${exception}" />-->
29
-    <!--错误提示-->
30
-    
31
-
32
-    <target name="error_file" xsi:type="File" fileName="log/${shortdate}/error-${shortdate}.log"
33
-            archiveFileName="log/${shortdate}/own-${shortdate}.{#####}.log"
34
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false" 
35
-            layout="${level}|记录时间:${longdate}|控制器:${logger}|action: ${aspnet-mvc-action}|${newline}消息:${message}|${newline}异常:${onexception:${exception:format=tostring} ${newline} ${stacktrace}|${newline}" />
36
-    <target name="debugger_file" xsi:type="File" fileName="log/${shortdate}/debugger-${shortdate}.log"
37
-            archiveFileName="log/${shortdate}/debugger-${shortdate}.{#####}.log"
38
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false"
39
-            layout="${level}|记录时间:${longdate}|控制器:${logger}|action: ${aspnet-mvc-action}|消息:${message}|${newline}" />
40
-     <target name="warn_file" xsi:type="File" fileName="log/${shortdate}/warn-${shortdate}.log"
41
-            archiveFileName="log/${shortdate}/warn-${shortdate}.{#####}.log"
42
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false" 
43
-            layout="${level}|记录时间:${longdate}|控制器:${logger}|action: ${aspnet-mvc-action}|消息:${message}|${newline}" />
44
-    <!-- write to the void aka just remove -->
45
-    <target xsi:type="Null" name="blackhole" />
46
-  </targets>
47
-
48
-  <!-- 写入目的地的规则 -->
49
-  <rules>
50
-    <!--全部记录,包括Microsoft开头的相关日志信息-->
51
-    <!--<logger name="*" minlevel="Trace" writeTo="allfile" />-->
52
-
53
-    <!--name - 记录者的名字 (允许使用通配符*)
54
-        minlevel - 匹配日志范围的最低级别
55
-        maxlevel - 匹配日志范围的最高级别
56
-        level - 匹配的单一日志级别 :::::NLog 用于输出日志的级别包括:Trace,Debug,Info,Warn,Error,Fatal
57
-        levels - 匹配的一系列日志级别,由逗号分隔。
58
-        writeTo - 规则匹配时日志应该被写入的一系列目标,由逗号分隔。-->
59
-
60
-    <!--跳过Microsoft开头的相关日志信息-->
61
-    <!--<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />-->
62
-
63
-    <!--错误提示-->
64
-    <logger name="*" minlevel="Trace" writeTo="own_file" />
65
-    <logger name="*" level="Debug" writeTo="debugger_file" />
66
-    <logger name="*" minlevel="Error" writeTo="error_file" />
67
-    <logger name="*" level="Warn" writeTo="warn_file" />
68
- 
69
-
70
-  </rules>
71
-</nlog>

+ 0 - 51
MadRunFabric.WechatApi/WechatApi.IRepositories/ICall_RecordsRepository.cs

@@ -1,51 +0,0 @@
1
-using MadRunFabric.Common;
2
-using MadRunFabric.Model.CallCenterApi;
3
-using System;
4
-using System.Collections.Generic;
5
-using System.Text;
6
-
7
-namespace WechatApi.IRepositories
8
-{
9
-    public interface ICall_RecordsRepository : IRepository<mw_call_records, string>
10
-    {
11
-        /// <summary>
12
-        /// 获取坐席总数
13
-        /// </summary>
14
-        /// <returns></returns>
15
-        int GetUserCount();
16
-        /// <summary>
17
-        /// 获取通话量
18
-        /// </summary>
19
-        /// <param name="agentcode">坐席工号</param>
20
-        /// <param name="start">开始时间</param>
21
-        /// <param name="end">结束时间</param>
22
-        /// <param name="tag">呼叫类型</param>
23
-        /// <param name="state">呼叫状态</param>
24
-        /// <returns></returns>
25
-        object GetHighChartData(string agentcode, string start, string end, string tag, string state);
26
-        /// <summary>
27
-        /// 获取通话时长
28
-        /// </summary>
29
-        /// <param name="agentcode">坐席工号</param>
30
-        /// <param name="start">开始时间</param>
31
-        /// <param name="end">结束时间</param>
32
-        /// <param name="tag">呼叫类型</param>
33
-        /// <param name="state">呼叫状态</param>
34
-        object GetCallRecordTotalTime(string agentcode, string tag, string start, string end, string state);
35
-
36
-        /// <summary>
37
-        /// 获取24小时情况
38
-        /// </summary>
39
-        /// <param name="agentcode">坐席工号</param>
40
-        /// <param name="stime">开始时间</param>
41
-        /// <param name="etime">结束时间</param>
42
-        object GetHW24CountReport(string agentcode, string stime, string etime);
43
-        /// <summary>
44
-        /// 坐席状态统计
45
-        /// </summary>
46
-        /// <param name="agentcode"></param>
47
-        /// <param name="start"></param>
48
-        /// <param name="end"></param>
49
-        object GetAgentState(string agentcode, string start, string end);
50
-    }
51
-}

+ 0 - 13
MadRunFabric.WechatApi/WechatApi.IRepositories/ILocationRepository.cs

@@ -1,13 +0,0 @@
1
-using MadRunFabric.Common;
2
-using System;
3
-using System.Collections.Generic;
4
-using System.Text;
5
-using MadRunFabirc.Model;
6
-
7
-namespace WechatApi.IRepositories
8
-{
9
-    public interface ILocationRepository : IRepository<Location, string>
10
-    {
11
-
12
-    }
13
-}

+ 0 - 12
MadRunFabric.WechatApi/WechatApi.IRepositories/ISys_User_AccountRepository.cs

@@ -1,12 +0,0 @@
1
-using MadRunFabric.Common;
2
-using MadRunFabric.Model;
3
-using System;
4
-using System.Collections.Generic;
5
-using System.Text;
6
-
7
-namespace WechatApi.IRepositories
8
-{
9
-    public interface ISys_User_AccountRepository : IRepository<Sys_User_Account, string>
10
-    {
11
-    }
12
-}

+ 0 - 13
MadRunFabric.WechatApi/WechatApi.IRepositories/WechatApi.IRepositories.csproj

@@ -1,13 +0,0 @@
1
-<Project Sdk="Microsoft.NET.Sdk">
2
-
3
-  <PropertyGroup>
4
-    <TargetFramework>netcoreapp2.0</TargetFramework>
5
-  </PropertyGroup>
6
-
7
-  <ItemGroup>
8
-    <ProjectReference Include="..\..\MadRunFabirc.Model\MadRunFabric.Model.csproj" />
9
-    <ProjectReference Include="..\..\MadRunFabric.Common\MadRunFabric.Common.csproj" />
10
-    <ProjectReference Include="..\WechatApi.Model\WechatApi.Model.csproj" />
11
-  </ItemGroup>
12
-
13
-</Project>

+ 0 - 11
MadRunFabric.WechatApi/WechatApi.Model/WechatApi.Model.csproj

@@ -1,11 +0,0 @@
1
-<Project Sdk="Microsoft.NET.Sdk">
2
-
3
-  <PropertyGroup>
4
-    <TargetFramework>netcoreapp2.0</TargetFramework>
5
-  </PropertyGroup>
6
-
7
-  <ItemGroup>
8
-    <ProjectReference Include="..\..\MadRunFabric.Common\MadRunFabric.Common.csproj" />
9
-  </ItemGroup>
10
-
11
-</Project>

+ 0 - 456
MadRunFabric.WechatApi/WechatApi.Repositories/Call_RecordsRepository.cs

@@ -1,456 +0,0 @@
1
-using MadRunFabric.Common;
2
-using MadRunFabric.Common.Options;
3
-using MadRunFabric.Model;
4
-using MadRunFabric.Model.CallCenterApi;
5
-using Microsoft.Extensions.Logging;
6
-using Microsoft.Extensions.Options;
7
-using MongoDB.Bson;
8
-using MongoDB.Driver;
9
-using System;
10
-using System.Collections.Generic;
11
-using System.IO;
12
-using System.Linq;
13
-using System.Text;
14
-using WechatApi.IRepositories;
15
-
16
-namespace WechatApi.Repositories
17
-{
18
-    public class Call_RecordsRepository : BaseRepository<mw_call_records, string>, ICall_RecordsRepository
19
-    {
20
-        protected readonly ILogger<BaseRepository<mw_call_records, string>> _logger;
21
-        protected readonly IMongoCollection<mw_call_records> _collection_mw_call_records;
22
-        protected readonly IMongoCollection<Sys_User_Account> _collection_sys_user_account;
23
-        protected readonly IMongoCollection<MW_Agent_State_Record> _collection_mw_agent_state_record;
24
-        public Call_RecordsRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<mw_call_records, string>> logger) : base(settings, logger)
25
-        {
26
-            _logger = logger;
27
-            _collection_mw_call_records = _context.GetCollection<mw_call_records>();
28
-            _collection_sys_user_account = _context.GetCollection<Sys_User_Account>();
29
-        }
30
-
31
-        /// <summary>
32
-        /// 获取坐席总数
33
-        /// </summary>
34
-        /// <returns></returns>
35
-        public int GetUserCount()
36
-        {
37
-            var users = from sysuser in _collection_sys_user_account.AsQueryable()
38
-                        where sysuser.delete_flag == false
39
-                        select sysuser;
40
-
41
-            return users.Count();
42
-        }
43
-        /// <summary>
44
-        /// 获取通话量
45
-        /// </summary>
46
-        /// <param name="agentcode">坐席工号</param>
47
-        /// <param name="start">开始时间</param>
48
-        /// <param name="end">结束时间</param>
49
-        /// <param name="tag">呼叫类型</param>
50
-        /// <param name="state">呼叫状态</param>
51
-        public object GetHighChartData(string agentcode, string start, string end, string tag, string state)
52
-        {
53
-            #region 条件搜索
54
-            string bxwhere = "";
55
-            if (!string.IsNullOrEmpty(tag))
56
-            {
57
-                if (bxwhere != "")
58
-                {
59
-                    bxwhere = bxwhere + ",{calltype:" + tag + "}";
60
-                }
61
-                else
62
-                {
63
-                    bxwhere = "{calltype:" + tag + "}";
64
-                }
65
-            }
66
-            if (!string.IsNullOrEmpty(state))
67
-            {
68
-                if (bxwhere != "")
69
-                {
70
-                    bxwhere = bxwhere + ",{callstate:" + state + "}";
71
-                }
72
-                else
73
-                {
74
-                    bxwhere = "{callstate:" + state + "}";
75
-                }
76
-            }
77
-            if (!string.IsNullOrEmpty(agentcode))
78
-            {
79
-                if (bxwhere != "")
80
-                {
81
-                    bxwhere = bxwhere + ",{agent_code:'" + agentcode + "'}";
82
-                }
83
-                else
84
-                {
85
-                    bxwhere = "{agent_code:'" + agentcode + "'}";
86
-                }
87
-            }
88
-
89
-            if (!string.IsNullOrEmpty(start))
90
-            {
91
-                if (bxwhere != "")
92
-                {
93
-                    bxwhere = bxwhere + ",{begintime:{$gte:new Date('" + start + "')}}";
94
-                }
95
-                else
96
-                {
97
-                    bxwhere = "{begintime:{$gte:new Date('" + start + "')}}";
98
-                }
99
-
100
-            }
101
-            if (!string.IsNullOrEmpty(end))
102
-            {
103
-                if (bxwhere != "")
104
-                {
105
-                    bxwhere = bxwhere + ",{begintime:{$lte:new Date('" + end + "')}}";
106
-                }
107
-                else
108
-                {
109
-                    bxwhere = "{begintime:{$lte:new Date('" + end + "')}}";
110
-                }
111
-
112
-            }
113
-            #endregion
114
-            var bxstages = new List<IPipelineStageDefinition>();
115
-            bxstages.Add(new JsonPipelineStageDefinition<mw_call_records, BsonDocument>("{$match:{$and:[" + bxwhere + "]}}"));
116
-            bxstages.Add(new JsonPipelineStageDefinition<BsonDocument, BsonDocument>("{$group:{_id:\"$id\", count: {$sum: 1}}}"));
117
-            var bxpipeline = new PipelineStagePipelineDefinition<mw_call_records, BsonDocument>(bxstages);
118
-            var bxresult = _collection_mw_call_records.Aggregate(bxpipeline).ToList();
119
-            if (bxresult.Count > 0)
120
-            {
121
-                return bxresult[0]["count"];
122
-            }
123
-            else
124
-            { return "0"; }
125
-
126
-        }
127
-        /// <summary>
128
-        /// 获取通话时长
129
-        /// </summary>
130
-        /// <param name="agentcode">坐席工号</param>
131
-        /// <param name="start">开始时间</param>
132
-        /// <param name="end">结束时间</param>
133
-        /// <param name="tag">呼叫类型</param>
134
-        /// <param name="state">呼叫状态</param>
135
-        public object GetCallRecordTotalTime(string agentcode, string tag, string start, string end, string state)
136
-        {
137
-            #region 条件搜索
138
-            string bxwhere = "";
139
-            if (!string.IsNullOrEmpty(tag))
140
-            {
141
-                if (bxwhere != "")
142
-                {
143
-                    bxwhere = bxwhere + ",{calltype:" + tag + "}";
144
-                }
145
-                else
146
-                {
147
-                    bxwhere = "{calltype:" + tag + "}";
148
-                }
149
-            }
150
-            if (!string.IsNullOrEmpty(state))
151
-            {
152
-                if (bxwhere != "")
153
-                {
154
-                    bxwhere = bxwhere + ",{callstate:" + state + "}";
155
-                }
156
-                else
157
-                {
158
-                    bxwhere = "{callstate:" + state + "}";
159
-                }
160
-            }
161
-            if (!string.IsNullOrEmpty(agentcode))
162
-            {
163
-                if (bxwhere != "")
164
-                {
165
-                    bxwhere = bxwhere + ",{agent_code:'" + agentcode + "'}";
166
-                }
167
-                else
168
-                {
169
-                    bxwhere = "{agent_code:'" + agentcode + "'}";
170
-                }
171
-            }
172
-
173
-            if (!string.IsNullOrEmpty(start))
174
-            {
175
-                if (bxwhere != "")
176
-                {
177
-                    bxwhere = bxwhere + ",{begintime:{$gte:new Date('" + start + "')}}";
178
-                }
179
-                else
180
-                {
181
-                    bxwhere = "{begintime:{$gte:new Date('" + start + "')}}";
182
-                }
183
-
184
-            }
185
-            if (!string.IsNullOrEmpty(end))
186
-            {
187
-                if (bxwhere != "")
188
-                {
189
-                    bxwhere = bxwhere + ",{begintime:{$lte:new Date('" + end + "')}}";
190
-                }
191
-                else
192
-                {
193
-                    bxwhere = "{begintime:{$lte:new Date('" + end + "')}}";
194
-                }
195
-
196
-            }
197
-            #endregion
198
-            var bxstages = new List<IPipelineStageDefinition>();
199
-            bxstages.Add(new JsonPipelineStageDefinition<mw_call_records, BsonDocument>("{$match:{$and:[" + bxwhere + "]}}"));//agent_code
200
-            bxstages.Add(new JsonPipelineStageDefinition<BsonDocument, BsonDocument>("{$group:{_id:\"$id\", count: {$sum: 1},totalcount:{$sum:\"$longs_talk\"}}}"));
201
-            var bxpipeline = new PipelineStagePipelineDefinition<mw_call_records, BsonDocument>(bxstages);
202
-            var bxresult = _collection_mw_call_records.Aggregate(bxpipeline).ToList();
203
-            if (bxresult.Count > 0)
204
-            {
205
-                return bxresult[0]["count"] + "," + bxresult[0]["totalcount"];
206
-            }
207
-            else
208
-            { return "0,0"; }
209
-        }
210
-
211
-        /// <summary>
212
-        /// 获取日周月年话务数据24小时统计
213
-        /// </summary>
214
-        /// <param name="stime"></param>
215
-        /// <param name="etime"></param>
216
-        /// <returns></returns>
217
-        public object GetHW24CountReport(string agentcode, string stime, string etime)
218
-        {
219
-            int[] hours = Enumerable.Range(0, 24).ToArray<int>();
220
-            int[] counts = new int[24];
221
-            int[] yjrcounts = new int[24];
222
-            int[] wjrcounts = new int[24];
223
-
224
-            var query = from p in _collection.AsQueryable() where 1 == 1 select p;
225
-            if (!string.IsNullOrEmpty(agentcode))
226
-                query = query.Where(it => it.agent_code.Equals(agentcode));
227
-            if (!string.IsNullOrEmpty(stime))
228
-                query = query.Where(it => it.begintime >= Convert.ToDateTime(stime));
229
-            if (!string.IsNullOrEmpty(etime))
230
-                query = query.Where(it => it.begintime <= Convert.ToDateTime(etime));
231
-
232
-            var list = query.ToList();
233
-            for (int i = 0; i < hours.Length; i++)
234
-            {
235
-                counts[i] = list.Where(it => it.begintime.Hour == i).Count();
236
-            }
237
-
238
-            #region 已接入
239
-            var query1 = from p in _collection.AsQueryable() where p.callstate == 1 select p;
240
-            if (!string.IsNullOrEmpty(agentcode))
241
-                query1 = query1.Where(it => it.agent_code.Equals(agentcode));
242
-            if (!string.IsNullOrEmpty(stime))
243
-                query1 = query1.Where(it => it.begintime >= Convert.ToDateTime(stime));
244
-            if (!string.IsNullOrEmpty(etime))
245
-                query1 = query1.Where(it => it.begintime <= Convert.ToDateTime(etime));
246
-
247
-            var list1 = query1.ToList();
248
-            for (int i = 0; i < hours.Length; i++)
249
-            {
250
-                yjrcounts[i] = list1.Where(it => it.begintime.Hour == i).Count();
251
-            }
252
-            #endregion
253
-
254
-            #region 未接入
255
-            var query2 = from p in _collection.AsQueryable() where p.callstate == 0 select p;
256
-            if (!string.IsNullOrEmpty(agentcode))
257
-                query2 = query2.Where(it => it.agent_code.Equals(agentcode));
258
-            if (!string.IsNullOrEmpty(stime))
259
-                query2 = query2.Where(it => it.begintime >= Convert.ToDateTime(stime));
260
-            if (!string.IsNullOrEmpty(etime))
261
-                query2 = query2.Where(it => it.begintime <= Convert.ToDateTime(etime));
262
-
263
-            var list2 = query2.ToList();
264
-            for (int i = 0; i < hours.Length; i++)
265
-            {
266
-                wjrcounts[i] = list2.Where(it => it.begintime.Hour == i).Count();
267
-            }
268
-            #endregion
269
-
270
-            var result = new
271
-            {
272
-                hours,
273
-                counts,
274
-                yjrcounts,
275
-                wjrcounts
276
-            };
277
-            return result;
278
-        }
279
-
280
-        /// <summary>
281
-        /// 坐席状态统计
282
-        /// </summary>
283
-        /// <param name="agentcode"></param>
284
-        /// <param name="start"></param>
285
-        /// <param name="end"></param>
286
-        /// <returns></returns>
287
-        public object GetAgentState(string agentcode, string start, string end)
288
-        {
289
-            #region 条件搜索
290
-            string bxwhere = "";
291
-            if (!string.IsNullOrEmpty(agentcode))
292
-            {
293
-                if (bxwhere != "")
294
-                {
295
-                    bxwhere = bxwhere + ",{agent_id:" + agentcode + "}";
296
-                }
297
-                else
298
-                {
299
-                    bxwhere = "{agent_id:" + agentcode + "}";
300
-                }
301
-            }
302
-
303
-            if (!string.IsNullOrEmpty(start))
304
-            {
305
-                if (bxwhere != "")
306
-                {
307
-                    bxwhere = bxwhere + ",{time_login:{$gte:new Date('" + start + "')}}";
308
-                }
309
-                else
310
-                {
311
-                    bxwhere = "{time_login:{$gte:new Date('" + start + "')}}";
312
-                }
313
-
314
-            }
315
-            if (!string.IsNullOrEmpty(end))
316
-            {
317
-                if (bxwhere != "")
318
-                {
319
-                    bxwhere = bxwhere + ",{time_login:{$lte:new Date('" + end + "')}}";
320
-                }
321
-                else
322
-                {
323
-                    bxwhere = "{time_login:{$lte:new Date('" + end + "')}}";
324
-                }
325
-
326
-            }
327
-            #endregion
328
-            
329
-            var bxstages = new List<IPipelineStageDefinition>();
330
-            bxstages.Add(new JsonPipelineStageDefinition<MW_Agent_State_Record, BsonDocument>("{$match:{$and:[" + bxwhere + "]}}"));//agent_code
331
-            bxstages.Add(new JsonPipelineStageDefinition<BsonDocument, BsonDocument>("{$group:{_id:\"$id\", logintimes:{$sum:\"$login_times\"}, freetimes:{$sum:\"free_times\"}, reposetimes:{$sum:\"repose_times\"}, talktimes:{$sum:\"talk_times\"}, reposenum:{$sum:\"repose_num\"}, answernum:{$sum:\"answer_num\"}}}"));
332
-            var bxpipeline = new PipelineStagePipelineDefinition<MW_Agent_State_Record, BsonDocument>(bxstages);
333
-            var bxresult = _collection_mw_agent_state_record.Aggregate(bxpipeline).ToList();
334
-            if (bxresult.Count > 0)
335
-            {
336
-                var obj = new {
337
-                    logintimes = bxresult[0]["logintimes"],
338
-                    freetimes = bxresult[0]["freetimes"],
339
-                    reposetimes = bxresult[0]["reposetimes"],
340
-                    talktimes = bxresult[0]["talktimes"],
341
-                    reposenum = bxresult[0]["reposenum"],
342
-                    answernum = bxresult[0]["answernum"],
343
-                };
344
-                return obj;
345
-            }
346
-            else
347
-            { return null; }
348
-        }
349
-            #region
350
-            ///// <summary>
351
-            ///// 获取24小时通话情况
352
-            ///// </summary>
353
-            ///// <param name="agentcode">坐席工号</param>
354
-            ///// <param name="start">开始时间</param>
355
-            ///// <param name="end">结束时间</param>
356
-            ///// <param name="tag">呼叫类型</param>
357
-            ///// <param name="state">呼叫状态</param>
358
-            //public object Get24HourCall(string agentcode, string tag, string start, string end, string state)
359
-            //{
360
-            //    #region 条件搜索
361
-            //    string bxwhere = ""; 
362
-            //    if (!string.IsNullOrEmpty(tag))
363
-            //    {
364
-            //        if (bxwhere != "")
365
-            //        {
366
-            //            bxwhere = bxwhere + ",{calltype:" + tag + "}";
367
-            //        }
368
-            //        else
369
-            //        {
370
-            //            bxwhere = "{calltype:" + tag + "}";
371
-            //        }
372
-            //    }
373
-            //    if (!string.IsNullOrEmpty(state))
374
-            //    {
375
-            //        if (bxwhere != "")
376
-            //        {
377
-            //            bxwhere = bxwhere + ",{callstate:" + state + "}";
378
-            //        }
379
-            //        else
380
-            //        {
381
-            //            bxwhere = "{callstate:" + state + "}";
382
-            //        }
383
-            //    }
384
-            //    if (!string.IsNullOrEmpty(agentcode))
385
-            //    {
386
-            //        if (bxwhere != "")
387
-            //        {
388
-            //            bxwhere = bxwhere + ",{agent_code:'" + agentcode + "'}";
389
-            //        }
390
-            //        else
391
-            //        {
392
-            //            bxwhere = "{agent_code:'" + agentcode + "'}";
393
-            //        }
394
-            //    }
395
-
396
-            //    if (!string.IsNullOrEmpty(start))
397
-            //    {
398
-            //        if (bxwhere != "")
399
-            //        {
400
-            //            bxwhere = bxwhere + ",{begintime:{$gte:new Date('" + start + "')}}";
401
-            //        }
402
-            //        else
403
-            //        {
404
-            //            bxwhere = "{begintime:{$gte:new Date('" + start + "')}}";
405
-            //        }
406
-
407
-            //    }
408
-            //    if (!string.IsNullOrEmpty(end))
409
-            //    {
410
-            //        if (bxwhere != "")
411
-            //        {
412
-            //            bxwhere = bxwhere + ",{begintime:{$lte:new Date('" + end + "')}}";
413
-            //        }
414
-            //        else
415
-            //        {
416
-            //            bxwhere = "{begintime:{$lte:new Date('" + end + "')}}";
417
-            //        }
418
-
419
-            //    }
420
-            //    #endregion
421
-
422
-            //    var bxstages = new List<IPipelineStageDefinition>();
423
-            //    bxstages.Add(new JsonPipelineStageDefinition<mw_call_records, BsonDocument>("{$match:{$and:[" + bxwhere + "]}}"));//agent_code
424
-            //    bxstages.Add(new JsonPipelineStageDefinition<BsonDocument, BsonDocument>("{$group:{_id:{$hour: {$add:[\"begintime\",28800000]} }, count: {$sum: 1},longs:{$sum:\"$longs_talk\"}}}"));
425
-            //    var bxpipeline = new PipelineStagePipelineDefinition<mw_call_records, BsonDocument>(bxstages);
426
-            //    var bxresult = _collection_mw_call_records.Aggregate(bxpipeline).ToList();
427
-
428
-            //    int[] hours = Enumerable.Range(0, 24).ToArray<int>();
429
-            //    string[] counts = new string[24];//数量
430
-            //    string[] longs = new string[24];//时长
431
-
432
-            //    for (int i = 0; i < hours.Length; i++)
433
-            //    {
434
-            //        counts[i] = "0";
435
-            //        longs[i] = "0";
436
-
437
-            //        var bx = bxresult.Where(p => p.Values.ToArray()[0].ToString() == i.ToString()).FirstOrDefault();
438
-            //        if (bx != null)
439
-            //        {
440
-            //            counts[i] = bx.Values.ToArray()[1].ToString();
441
-            //            longs[i] = bx.Values.ToArray()[2].ToString();
442
-            //        }
443
-            //    }
444
-
445
-            //    var obj = new
446
-            //    {
447
-            //        hours,
448
-            //        counts,
449
-            //        longs,
450
-            //    };
451
-
452
-            //    return obj;
453
-            //}
454
-            #endregion
455
-        }
456
-}

+ 0 - 21
MadRunFabric.WechatApi/WechatApi.Repositories/LocationRepository.cs

@@ -1,21 +0,0 @@
1
-using MadRunFabirc.Model;
2
-using MadRunFabric.Common;
3
-using MadRunFabric.Common.Options;
4
-using Microsoft.Extensions.Logging;
5
-using Microsoft.Extensions.Options;
6
-using System;
7
-using System.Collections.Generic;
8
-using System.Text;
9
-using WechatApi.IRepositories;
10
-
11
-namespace WechatApi.Repositories
12
-{
13
-    public class LocationRepository : BaseRepository<Location, string>, ILocationRepository
14
-    {
15
-        public LocationRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<Location, string>> logger) : base(settings, logger)
16
-        {
17
-
18
-        }
19
-
20
-    }
21
-}

+ 0 - 21
MadRunFabric.WechatApi/WechatApi.Repositories/Sys_User_AccountRepository.cs

@@ -1,21 +0,0 @@
1
-using MadRunFabric.Common;
2
-using MadRunFabric.Common.Options;
3
-using MadRunFabric.Model;
4
-using Microsoft.Extensions.Logging;
5
-using Microsoft.Extensions.Options;
6
-using System;
7
-using System.Collections.Generic;
8
-using System.Text;
9
-using WechatApi.IRepositories;
10
-
11
-namespace WechatApi.Repositories
12
-{
13
-    public class Sys_User_AccountRepository : BaseRepository<Sys_User_Account, string>, ISys_User_AccountRepository
14
-    {
15
-        protected readonly ILogger<BaseRepository<Sys_User_Account, string>> _logger;
16
-        public Sys_User_AccountRepository(IOptions<MongodbOptions> settings, ILogger<BaseRepository<Sys_User_Account, string>> logger) : base(settings, logger)
17
-        {
18
-            _logger = logger;
19
-        }
20
-    }
21
-}

+ 0 - 12
MadRunFabric.WechatApi/WechatApi.Repositories/WechatApi.Repositories.csproj

@@ -1,12 +0,0 @@
1
-<Project Sdk="Microsoft.NET.Sdk">
2
-
3
-  <PropertyGroup>
4
-    <TargetFramework>netcoreapp2.0</TargetFramework>
5
-  </PropertyGroup>
6
-
7
-  <ItemGroup>
8
-    <ProjectReference Include="..\WechatApi.IRepositories\WechatApi.IRepositories.csproj" />
9
-    <ProjectReference Include="..\WechatApi.Model\WechatApi.Model.csproj" />
10
-  </ItemGroup>
11
-
12
-</Project>

+ 0 - 113
MadRunFabric.WechatApi/WechatApi/Controllers/HomeController.cs

@@ -1,113 +0,0 @@
1
-using System;
2
-using System.IO;
3
-using System.Text;
4
-using System.Threading.Tasks;
5
-using Api.SignToken;
6
-using MadRunFabric.Common;
7
-using Microsoft.AspNetCore.Hosting;
8
-using Microsoft.AspNetCore.Mvc;
9
-using Microsoft.Extensions.Configuration;
10
-using NLog;
11
-using Senparc.Weixin.MP;
12
-using Senparc.Weixin.MP.Containers;
13
-using Senparc.Weixin.MP.Entities.Request;
14
-using Senparc.Weixin.MP.Helpers;
15
-using Senparc.Weixin.MP.MvcExtension;
16
-using WechatApi.MessageHandlers;
17
-
18
-
19
-namespace WechatApi.Controllers
20
-{
21
-    [ApiVersion("6.0")]
22
-    [Produces("application/json")]
23
-    [Route("api/Home/[action]")]
24
-    public class HomeController : BaseController
25
-    {
26
-        private readonly string Token;
27
-        private readonly string AppId;
28
-        private readonly string AppSecret;
29
-        private readonly string EncodingAESKey;
30
-        static Logger Logger = LogManager.GetCurrentClassLogger();
31
-        private readonly ISignTokenService _signTokenService;
32
-        private IHostingEnvironment _host;
33
-        private IConfiguration _configuration;
34
-        public HomeController(IConfiguration configuration, ISignTokenService signTokenService, IHostingEnvironment host)
35
-        {
36
-            Token = configuration["WechatStatic:Token"];
37
-            AppId = configuration["WechatStatic:AppId"];
38
-            AppSecret = configuration["WechatStatic:AppSecret"];
39
-            EncodingAESKey = configuration["WechatStatic:EncodingAESKey"];
40
-            _configuration = configuration;
41
-            _signTokenService = signTokenService;
42
-            _host = host;
43
-        }
44
-
45
-        /// <summary>
46
-        /// 微信开发验证
47
-        /// </summary>
48
-        /// <param name="signature"></param>
49
-        /// <param name="timestamp"></param>
50
-        /// <param name="nonce"></param>
51
-        /// <param name="echostr"></param>
52
-        /// <returns></returns>
53
-        [HttpGet]
54
-        public IActionResult Verify(string signature, string timestamp, string nonce, string echostr)
55
-        {
56
-            if (CheckSignature.Check(signature, timestamp, nonce, Token))
57
-            {
58
-                return Content(echostr, "application/x-www-form-urlencoded", Encoding.UTF8); //返回随机字符串则表示验证通过
59
-            }
60
-            return Content($"failed:{signature},{CheckSignature.GetSignature(timestamp, nonce, Token) }。如果您在浏览器中看到这条信息,表明此Url可以填入微信后台。");
61
-        }
62
-
63
-        /// <summary>
64
-        /// 用户发送消息后,微信平台自动Post一个请求到这里,并等待响应XML。
65
-        /// </summary>
66
-        [HttpPost]
67
-        [Produces("text/xml")]
68
-        public IActionResult Verify(PostModel postModel)
69
-        {
70
-            if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, Token))
71
-            {
72
-                return new WeixinResult("参数错误");
73
-            }
74
-            postModel.Token = Token;
75
-            postModel.EncodingAESKey = EncodingAESKey;
76
-            postModel.AppId = AppId;
77
-
78
-            string body = new StreamReader(Request.Body).ReadToEnd();
79
-            byte[] requestData = Encoding.UTF8.GetBytes(body);
80
-            Stream inputStream = new MemoryStream(requestData);
81
-
82
-
83
-            CustomMessageHandler messageHandler = new CustomMessageHandler(inputStream, postModel, _configuration, _signTokenService);//接收消息
84
-            messageHandler.Execute();//执行微信处理过程
85
-
86
-            return new FixWeixinBugWeixinResult(messageHandler);//返回结果、、
87
-            //最终返回结果是:【xml文档转为xml字符串并且去掉“换行”、“空格”后的字符串】
88
-            //return new WeixinResult(messageHandler.FinalResponseDocument.ToString().Replace("\r\n", "").Replace(" ", ""));
89
-        }
90
-
91
-        /// <summary>
92
-        /// 供前端调用JSSDK,获取基本验证信息
93
-        /// </summary>
94
-        /// <returns></returns>
95
-        [HttpGet]
96
-        public async Task<IActionResult> GetInfo(string fromUrl = "")
97
-        {
98
-            var timestamp = JSSDKHelper.GetTimestamp(); //获取随机码
99
-            var nonce = JSSDKHelper.GetNoncestr();
100
-            var ticket = await JsApiTicketContainer.GetJsApiTicketAsync(AppId);
101
-            var signature = JSSDKHelper.GetSignature(ticket.ToString(), nonce, timestamp, fromUrl);
102
-            return Success("", new
103
-            {
104
-                appid = AppId,
105
-                timestamp,
106
-                nonce,
107
-                signature,
108
-                ticket,
109
-                fromUrl
110
-            });
111
-        }
112
-    }
113
-}

+ 0 - 26
MadRunFabric.WechatApi/WechatApi/Controllers/Info/InfoController.cs

@@ -1,26 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using Microsoft.AspNetCore.Http;
6
-using Microsoft.AspNetCore.Mvc;
7
-using Microsoft.AspNetCore.Authorization;
8
-using MadRunFabric.Common;
9
-
10
-namespace EquipmentApi.Controllers.Info
11
-{
12
-    [ApiVersion("6.0")]
13
-    [AllowAnonymous]
14
-    [Produces("application/json")]
15
-    [Route("api/Info")]
16
-    public class InfoController : BaseController
17
-    {
18
-        [HttpGet]
19
-        public IEnumerable<string> Get()
20
-        {
21
-            return new string[] { $"版本信息 {RequestedApiVersion}","开发团队: Mad Fun Fabric" };
22
-        }
23
-
24
-        protected ApiVersion RequestedApiVersion => HttpContext.GetRequestedApiVersion();
25
-    }
26
-}

+ 0 - 155
MadRunFabric.WechatApi/WechatApi/Controllers/LocationController.cs

@@ -1,155 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Security.Claims;
5
-using System.Threading.Tasks;
6
-using MadRunFabirc.Model;
7
-using MadRunFabric.Common;
8
-using Microsoft.AspNetCore.Authorization;
9
-using Microsoft.AspNetCore.Mvc;
10
-using Microsoft.Extensions.Caching.Distributed;
11
-using Microsoft.Extensions.Configuration;
12
-using Microsoft.Extensions.Logging;
13
-using MongoDB.Driver;
14
-using Newtonsoft.Json;
15
-using WechatApi.IRepositories;
16
-using WechatApi.Model;
17
-
18
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
19
-
20
-namespace WechatApi.Controllers
21
-{
22
-    [ApiVersion("6.0")]
23
-    //[Authorize]
24
-    [Produces("application/json")]
25
-    [Route("api/Location/[action]")]
26
-    public class LocationController : BaseController
27
-    {
28
-        private readonly ILogger<LocationController> _logger;
29
-        private readonly ILocationRepository _locationRepository;
30
-        private readonly IDistributedCache _cache;
31
-        private readonly IConfiguration _configuration;
32
-        //private 
33
-        public LocationController(
34
-            ILogger<LocationController> logger,
35
-            ILocationRepository locationRepository,
36
-            IDistributedCache cache,
37
-            IConfiguration configuration)
38
-        {
39
-            _logger = logger;
40
-            _locationRepository = locationRepository;
41
-            _cache = cache;
42
-            _configuration = configuration;
43
-        }
44
-
45
-        [Authorize]
46
-        /// <summary>
47
-        /// 供APP调用,APP发送定位信息到服务端
48
-        /// </summary>
49
-        /// <param name="input"></param>
50
-        /// <returns></returns>
51
-        [HttpPost]
52
-        public async Task<IActionResult> PutLocationAsync(LocationInput input)
53
-        {
54
-            #region 参数检查
55
-            if (string.IsNullOrWhiteSpace(input.Longitude))
56
-                return Error("经度是必需字段");
57
-            if (string.IsNullOrWhiteSpace(input.Latitude))
58
-                return Error("纬度是必需字段");
59
-            #endregion
60
-
61
-            #region 存入mongodb
62
-            var location = new Location
63
-            {
64
-                usercode = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value,
65
-                longitude = input.Longitude,
66
-                latitude = input.Latitude,
67
-                createtime = DateTime.Now.ToLocalTime()
68
-            };
69
-            var flag = await _locationRepository.Add(location);
70
-
71
-            #endregion
72
-
73
-
74
-            var timespan = 0;
75
-            int.TryParse(_configuration["AppSendLocationTimespan"], out timespan);
76
-            if (!flag)
77
-                return Error("定位存储操作失败");
78
-
79
-            #region 存入redis缓存
80
-            await _cache.SetStringAsync($"location{location.usercode}", location.ToJson());
81
-            #endregion
82
-
83
-            var resultobj = new object();
84
-
85
-            #region 根据经纬度获取位置详情--腾讯地图api
86
-            string url = _configuration["location:url"];
87
-            string key = _configuration["location:key"];
88
-            string poi = _configuration["location:poi"];
89
-
90
-            string strresult = HttpMethods.HttpGet(url + $"?location={location.longitude},{location.latitude}&key={key}&get_poi={poi}");
91
-            if (!string.IsNullOrEmpty(strresult))
92
-            {
93
-                var result = strresult.ToJObject();
94
-                if (result["status"].ToString() == "0")
95
-                {
96
-                    resultobj = result["result"];
97
-                }
98
-            } 
99
-            #endregion
100
-
101
-            var obj = new
102
-            {
103
-                timesapn = timespan > 0 ? timespan : 30,
104
-                result = resultobj
105
-            };
106
-
107
-            return Success("成功", obj);
108
-        }
109
-
110
-
111
-        /// <summary>
112
-        /// 供微信端调用,获取指定维修人员最新的定位信息
113
-        /// </summary>
114
-        /// <param name="input"></param>
115
-        /// <returns></returns>
116
-        [HttpGet]
117
-        public async Task<IActionResult> GetLocationAsync(string usercode = "")
118
-        {
119
-            #region 参数检查
120
-            if (string.IsNullOrWhiteSpace(usercode))
121
-                return Error("工号是必需字段");
122
-            #endregion
123
-
124
-            Location location = null;
125
-            #region 从Redis缓存中查询定位信息,如果Redis缓存中不存在,从MongoDB中查询
126
-
127
-            var locationStr = await _cache.GetStringAsync($"location{usercode}");
128
-            if (!string.IsNullOrWhiteSpace(locationStr))
129
-            {
130
-                //location = JsonConvert.DeserializeObject<List<Location>>(locationStr)
131
-                //   .Where(x => x.usercode == usercode)
132
-                //   .OrderBy(x => x.createtime).LastOrDefault();
133
-
134
-                location = locationStr.ToObject<Location>();
135
-            }
136
-
137
-            if (location == null)
138
-            {
139
-                var sort = Builders<Location>.Sort.Descending("createtime");
140
-                location = await _locationRepository.GetSingle(x => x.usercode == usercode, sort);
141
-            }
142
-
143
-            #endregion
144
-
145
-            if (location == null)
146
-                return Error("获取定位失败");
147
-
148
-            #region 存入redis缓存
149
-            await _cache.SetStringAsync($"location{location.usercode}", location.ToJson());
150
-            #endregion
151
-
152
-            return Success("成功", location);
153
-        }
154
-    }
155
-}

+ 0 - 107
MadRunFabric.WechatApi/WechatApi/Controllers/LoginController.cs

@@ -1,107 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using MadRunFabric.Common;
6
-using Microsoft.AspNetCore.Mvc;
7
-using Microsoft.Extensions.Configuration;
8
-using Senparc.Weixin.MP;
9
-using Senparc.Weixin.MP.AdvancedAPIs;
10
-using MadRunFabric.Model;
11
-using Api.SignToken;
12
-using Microsoft.Extensions.Logging;
13
-using NLog;
14
-using Microsoft.AspNetCore.Cors;
15
-using Senparc.Weixin.MP.Containers;
16
-using Microsoft.Net.Http.Headers;
17
-using Microsoft.Extensions.Caching.Distributed;
18
-
19
-namespace WechatApi.Controllers
20
-{
21
-    [ApiVersion("6.0")]
22
-    [Produces("application/json")]
23
-    [Route("api/[controller]")]
24
-    public class LoginController : BaseController
25
-    {
26
-        private readonly string AppId;
27
-        private readonly string AppSecret;
28
-        private readonly string FocusUrl;
29
-        private readonly string QRCodeTimeOut;
30
-        private readonly IDistributedCache _cache;
31
-        private readonly ISignTokenService _signTokenService;
32
-        static Logger Logger = LogManager.GetCurrentClassLogger();
33
-        public LoginController(IConfiguration configuration, IDistributedCache cache, ISignTokenService signTokenService)
34
-        {
35
-            AppId = configuration["WechatStatic:AppId"];
36
-            AppSecret = configuration["WechatStatic:AppSecret"];
37
-            FocusUrl = configuration["WechatStatic:FocusUrl"];
38
-            QRCodeTimeOut = configuration["WechatStatic:QRCodeTimeOut"];
39
-            _signTokenService = signTokenService;
40
-            _cache = cache;
41
-        }
42
-
43
-        /// <summary>
44
-        /// 获取UserInfo 和 Token
45
-        /// </summary>
46
-        /// <param name="wxLoginDto"></param>
47
-        /// <returns></returns>
48
-        [HttpPost("getuserinfotoken")]
49
-        public async Task<IActionResult> GetUserInfoTokenAsync(string code)
50
-        {
51
-            if (string.IsNullOrWhiteSpace(code))
52
-            {
53
-                var refurl = Request.Headers[HeaderNames.Referer].ToString();
54
-                var url = OAuthApi.GetAuthorizeUrl(AppId, refurl, "qwertyuidfghjkl", OAuthScope.snsapi_userinfo);
55
-                return Redirect("跳转", url);
56
-            }
57
-            var access = await OAuthApi.GetAccessTokenAsync(AppId, AppSecret, code);
58
-            var userinfo = await OAuthApi.GetUserInfoAsync(access.access_token, access.openid);
59
-
60
-            #region 发送请求获取系统内验证Token
61
-            var res = await _signTokenService.Wechat_LoginAsync(userinfo.openid, userinfo.nickname, userinfo.headimgurl);
62
-            #endregion
63
-
64
-            return Content(res);
65
-        }
66
-
67
-        /// <summary>
68
-        /// 获取UserInfo
69
-        /// </summary>
70
-        /// <param name="wxLoginDto"></param>
71
-        /// <returns></returns>
72
-        [HttpGet("getuserinfo")]
73
-        public IActionResult GetUserInfoAsync(string openid)
74
-        {
75
-            var accessToken = AccessTokenContainer.GetAccessToken(AppId);
76
-            Senparc.Weixin.MP.AdvancedAPIs.User.UserInfoJson userInfos = UserApi.Info(accessToken, openid);
77
-
78
-            return Success("成功", userInfos);
79
-        }
80
-
81
-        /// <summary>
82
-        /// 获取二维码图片
83
-        /// </summary>
84
-        /// <param name="wxLoginDto"></param>
85
-        /// <returns></returns>
86
-        [HttpGet("getqrcode")]
87
-        public async Task<IActionResult> GetQRCodeAsync(string usercode)
88
-        {
89
-            string url= await _cache.GetStringAsync($"qrcode{usercode}");
90
-            if (string.IsNullOrEmpty(url))
91
-            {
92
-                int timeout = int.Parse(QRCodeTimeOut);
93
-                var ExpirationTime = DateTime.Now.AddSeconds(timeout);
94
-                var accessToken = AccessTokenContainer.GetAccessToken(AppId);
95
-                var cre = await QrCodeApi.CreateAsync(accessToken, timeout, 1, QrCode_ActionName.QR_STR_SCENE, usercode);
96
-                url = QrCodeApi.GetShowQrCodeUrl(cre.ticket);
97
-
98
-                DistributedCacheEntryOptions options = new DistributedCacheEntryOptions();
99
-                options.AbsoluteExpiration = ExpirationTime;
100
-
101
-                await _cache.SetStringAsync($"qrcode{usercode}", url, options);
102
-            }
103
-
104
-            return Success("成功", url);
105
-        }
106
-    }
107
-}

+ 0 - 145
MadRunFabric.WechatApi/WechatApi/Controllers/MenuController.cs

@@ -1,145 +0,0 @@
1
-using System.IO;
2
-using System.Linq;
3
-using System.Text;
4
-using MadRunFabric.Common;
5
-using Microsoft.AspNetCore.Mvc;
6
-using Microsoft.Extensions.Configuration;
7
-using Newtonsoft.Json;
8
-using NLog;
9
-using Senparc.Weixin.MP.CommonAPIs;
10
-using Senparc.Weixin.MP.Entities.Menu;
11
-using WechatApi.Model;
12
-using MadRunFabric.Model;
13
-using Microsoft.Extensions.Logging;
14
-
15
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
16
-
17
-namespace WechatApi.Controllers
18
-{
19
-    [ApiVersion("6.0")]
20
-    [Produces("application/json")]
21
-    [Route("api/Menu/[action]")]
22
-    public class MenuController : BaseController
23
-    {
24
-        private readonly string Token;
25
-        private readonly string AppId;
26
-        private readonly string AppSecret;
27
-        private readonly string EncodingAESKey;
28
-        private readonly string MenuJson;
29
-        private readonly ILogger<MenuController> _logger;
30
-
31
-        public MenuController(ILogger<MenuController> logger, IConfiguration configuration)
32
-        {
33
-            _logger = logger;
34
-            Token = configuration["WechatStatic:Token"];
35
-            AppId = configuration["WechatStatic:AppId"];
36
-            AppSecret = configuration["WechatStatic:AppSecret"];
37
-            EncodingAESKey = configuration["WechatStatic:EncodingAESKey"];
38
-            MenuJson= configuration["WechatStatic:MenuJson"];
39
-        }
40
-
41
-
42
-        /// <summary>
43
-        /// 获取自定义菜单
44
-        /// </summary>
45
-        /// <returns></returns>
46
-        [HttpGet]
47
-        public IActionResult GetMenus()
48
-        {
49
-            var result = CommonApi.GetMenu(AppId);
50
-            return Success("", result);
51
-        }
52
-
53
-        /// <summary>
54
-        /// 创建/更新自定义菜单
55
-        /// </summary>
56
-        /// <returns></returns>
57
-        [HttpPost]
58
-        public IActionResult CreateMenus(string btnStr = "")
59
-        {
60
-            if (string.IsNullOrEmpty(btnStr))
61
-            {
62
-                btnStr = MenuJson;
63
-            }
64
-
65
-            var buttons = btnStr.ToList<MenuButton>();
66
-
67
-            ButtonGroup btnGroup = new ButtonGroup();
68
-
69
-            foreach (var button in buttons)
70
-            {
71
-                BaseButton baseButton = null;
72
-                SubButton subButton = null;
73
-                SingleButton singleButton = null;
74
-                if (button.sub_button.Count > 0)
75
-                {
76
-                    subButton = new SubButton { name = button.Name };
77
-
78
-                    foreach (var sub_button in button.sub_button)
79
-                    {
80
-                        if (sub_button.Type == "view")
81
-                        {
82
-                            singleButton = new SingleViewButton()
83
-                            {
84
-                                url = sub_button.Url,
85
-                                name = sub_button.Name
86
-                            };
87
-                        }
88
-                        else
89
-                        {
90
-                            singleButton = new SingleClickButton()
91
-                            {
92
-                                name = sub_button.Name,
93
-                                key = sub_button.Key,
94
-                                type = sub_button.Type,
95
-                            };
96
-                        }
97
-                        subButton.sub_button.Add(singleButton);
98
-                    }
99
-                }
100
-                else
101
-                {
102
-                    if (button.Type == "view")
103
-                    {
104
-                        baseButton = new SingleViewButton()
105
-                        {
106
-                            url = button.Url,
107
-                            name = button.Name
108
-                        };
109
-                    }
110
-                    else
111
-                    {
112
-                        baseButton = new SingleClickButton()
113
-                        {
114
-                            name = button.Name,
115
-                            key = button.Key,
116
-                            type = button.Type,
117
-                        };
118
-                    }
119
-                }
120
-                if (subButton != null && subButton.sub_button.Count > 0)
121
-                {
122
-                    btnGroup.button.Add(subButton);
123
-                }
124
-                else
125
-                {
126
-                    btnGroup.button.Add(baseButton);
127
-                }
128
-            }
129
-
130
-            var result = CommonApi.CreateMenu(AppId, btnGroup);
131
-            return Success("设置成功");
132
-        }
133
-
134
-        /// <summary>
135
-        /// 删除自定义菜单
136
-        /// </summary>
137
-        /// <returns></returns>
138
-        [HttpGet]
139
-        public IActionResult Delete()
140
-        {
141
-            var result = CommonApi.DeleteMenu(AppId);
142
-            return Success("", result);
143
-        }
144
-    }
145
-}

+ 0 - 114
MadRunFabric.WechatApi/WechatApi/Controllers/PaymentController.cs

@@ -1,114 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using MadRunFabric.Common;
6
-using Microsoft.AspNetCore.Mvc;
7
-using Microsoft.Extensions.Configuration;
8
-using Microsoft.Extensions.Logging;
9
-using NLog;
10
-using Senparc.Weixin.MP.TenPayLibV3;
11
-
12
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
13
-
14
-namespace WechatApi.Controllers
15
-{
16
-    [ApiVersion("6.0")]
17
-    [Produces("application/json")]
18
-    [Route("api/Payment/[action]")]
19
-    public class PaymentController : BaseController
20
-    {
21
-        private readonly string AppId;
22
-        private readonly string MchId;
23
-        private readonly string TenPayV3Notify;
24
-        private readonly string Key;
25
-
26
-        static Logger Logger = LogManager.GetCurrentClassLogger();
27
-
28
-        public PaymentController(IConfiguration configuration)
29
-        {
30
-            AppId = configuration["WechatStatic:AppId"];
31
-            MchId = configuration["WechatStatic:MchId"];
32
-            TenPayV3Notify = configuration["WechatStatic:TenPayV3Notify"];
33
-            Key = configuration["WechatStatic:Key"];
34
-        }
35
-        public IActionResult AdvancedPay()
36
-        {
37
-            #region 生成商户订单(系统内订单)TODO
38
-
39
-            #endregion
40
-
41
-
42
-            #region 调用微信统一下单API,生成预付单,获取预付单信息
43
-
44
-            var attach = "efg";
45
-            var body = "abc";
46
-            var openId = "oKOqcv_4HD3qeuf6aL5gaD--z4Xs";
47
-            var orderNum = DateTime.Now.ToString("yyyyMMddHHmmss");
48
-            var total_fee = "1";
49
-
50
-
51
-            RequestHandler requestHandler = new RequestHandler(HttpContext);
52
-            //微信分配的公众账号ID(企业号corpid即为此appId)
53
-            requestHandler.SetParameter("appid", AppId);
54
-            //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
55
-            requestHandler.SetParameter("attach", "attach");
56
-            //商品或支付单简要描述
57
-            requestHandler.SetParameter("body", "body");
58
-            //微信支付分配的商户号
59
-            requestHandler.SetParameter("mch_id", MchId);
60
-            //微信支付分配的商户号
61
-            // requestHandler.SetParameter("detail", "detail");
62
-            //随机字符串,不长于32位。
63
-            requestHandler.SetParameter("nonce_str", TenPayV3Util.GetNoncestr());
64
-            //接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
65
-            requestHandler.SetParameter("notify_url", TenPayV3Notify);
66
-            //trade_type=JSAPI,此参数必传,用户在商户公众号appid下的唯一标识。
67
-            requestHandler.SetParameter("openid", openId);
68
-            //商户系统内部的订单号,32个字符内、可包含字母,自己生成
69
-            requestHandler.SetParameter("out_trade_no", orderNum);
70
-            //APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
71
-            requestHandler.SetParameter("spbill_create_ip", "127.0.0.1");
72
-            //订单总金额,单位为分,做过银联支付的朋友应该知道,代表金额为12位,末位分分
73
-            requestHandler.SetParameter("total_fee", total_fee);
74
-            //取值如下:JSAPI,NATIVE,APP,我们这里使用JSAPI
75
-            requestHandler.SetParameter("trade_type", "JSAPI");
76
-            requestHandler.SetParameter("sign", requestHandler.CreateMd5Sign("key", Key));
77
-
78
-            string xml = requestHandler.ParseXML();
79
-            //获取并返回预支付XML信息
80
-            var result = TenPayV3.Unifiedorder(xml);
81
-            XmlHelper xmlHelper = new XmlHelper();
82
-            xmlHelper.LoadFromXmlString(result);
83
-
84
-            Logger.Info($"result={result}");
85
-            Logger.Info($"return_code={xmlHelper.GetValue("return_code")}");
86
-            Logger.Info($"return_msg={xmlHelper.GetValue("return_msg")}");
87
-
88
-            if (xmlHelper.GetValue("return_code") == "SUCCESS" && xmlHelper.GetValue("return_msg") == "OK")
89
-            {
90
-                return Success("预付单成功", new
91
-                {
92
-                    state = true,
93
-                    appid = AppId,
94
-                    package = xmlHelper.GetValue("prepay_id"),
95
-                    sign = xmlHelper.GetValue("sign"),
96
-                    noncestr = xmlHelper.GetValue("nonce_str"),
97
-                    timeStamp = DateTime.UtcNow.Ticks
98
-                });
99
-            }
100
-            return Error($"预付单失败。return_code={xmlHelper.GetValue("return_code")}, return_msg={ xmlHelper.GetValue("return_msg")}");
101
-            #endregion
102
-        }
103
-
104
-        public void callback()
105
-        {
106
-
107
-        }
108
-
109
-        private void GetPayInfo()
110
-        {
111
-
112
-        }
113
-    }
114
-}

+ 0 - 77
MadRunFabric.WechatApi/WechatApi/Controllers/SendMessageController.cs

@@ -1,77 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using MadRunFabric.Common;
6
-using Microsoft.AspNetCore.Mvc;
7
-using Microsoft.Extensions.Configuration;
8
-using Senparc.Weixin.MP.AdvancedAPIs;
9
-using Senparc.Weixin.MP.Containers;
10
-using Senparc.Weixin.MP.Entities;
11
-
12
-namespace WechatApi.Controllers
13
-{
14
-    [ApiVersion("6.0")]
15
-    [Produces("application/json")]
16
-    [Route("api/[controller]")]
17
-    public class SendMessageController : BaseController
18
-    {
19
-        private readonly string AppId;
20
-        private readonly string AppSecret;
21
-        private readonly string MessageUrl;
22
-        public SendMessageController(IConfiguration configuration)
23
-        {
24
-            AppId = configuration["WechatStatic:AppId"];
25
-            AppSecret = configuration["WechatStatic:AppSecret"];
26
-            MessageUrl = configuration["WechatStatic:MessageUrl"];
27
-        }
28
-
29
-        /// <summary>
30
-        /// 发送模板消息【需要安全验证】
31
-        /// </summary>
32
-        /// <returns></returns>
33
-        [HttpGet("testsend")]
34
-        public async Task<IActionResult> TestSendAsync(string openid)
35
-        {
36
-            List<Article> articles = new List<Article>();
37
-            Article ae = new Article();
38
-            ae.Title = "标题";
39
-            ae.Url = "http://www.baidu.com";
40
-            ae.Description = "内容";
41
-            articles.Add(ae);
42
-
43
-            var accessToken = AccessTokenContainer.GetAccessToken(AppId);
44
-            var result = await CustomApi.SendNewsAsync(accessToken, openid, articles);
45
-            return Success("OK", result);
46
-        }
47
-
48
-        /// <summary>
49
-        /// 发送模板消息【需要安全验证】
50
-        /// </summary>
51
-        /// <returns></returns>
52
-        [HttpPost("sendmessage")]
53
-        public async Task<IActionResult> SendMessageAsync(string openid,  string title, string content,string url)
54
-        {
55
-            if (MessageUrl.IndexOf("?") != -1)
56
-            {
57
-                url = MessageUrl + "&" + url;
58
-            }
59
-            else
60
-            {
61
-                url = MessageUrl + "?" + url;
62
-            }
63
-
64
-            List<Article> articles = new List<Article>();
65
-            Article ae = new Article();
66
-            ae.Title = title;
67
-            ae.Url = url;
68
-            ae.Description = content;
69
-            articles.Add(ae);
70
-
71
-            var accessToken = AccessTokenContainer.GetAccessToken(AppId);
72
-            var result = await CustomApi.SendNewsAsync(accessToken, openid, articles);
73
-
74
-            return Success("OK", result);
75
-        }
76
-    }
77
-}

+ 0 - 122
MadRunFabric.WechatApi/WechatApi/Controllers/TemplateMessageController.cs

@@ -1,122 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using MadRunFabric.Common;
6
-using Microsoft.AspNetCore.Mvc;
7
-using Microsoft.Extensions.Configuration;
8
-using Senparc.Weixin.MP.AdvancedAPIs;
9
-
10
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
11
-
12
-namespace WechatApi.Controllers
13
-{
14
-    [ApiVersion("6.0")]
15
-    [Produces("application/json")]
16
-    [Route("api/[controller]")]
17
-    public class TemplateMessageController : BaseController
18
-    {
19
-        private readonly string AppId;
20
-        private readonly string AppSecret;
21
-        private readonly string TemplateId;
22
-        private readonly string MessageUrl;
23
-        public TemplateMessageController(IConfiguration configuration)
24
-        {
25
-            AppId = configuration["WechatStatic:AppId"];
26
-            AppSecret = configuration["WechatStatic:AppSecret"];
27
-            TemplateId= configuration["WechatStatic:TemplateId"];
28
-            MessageUrl = configuration["WechatStatic:MessageUrl"];
29
-        }
30
-
31
-        /// <summary>
32
-        /// 发送模板消息【需要安全验证】
33
-        /// </summary>
34
-        /// <returns></returns>
35
-        [HttpGet("testsend")]
36
-        public async Task<IActionResult> TestSendAsync(string openid)
37
-        {
38
-            //var url = "http://www.baidu.com";
39
-            //var first = "你好,设备故障了!";
40
-            //var result = await TemplateApi.SendTemplateMessageAsync(
41
-            //AppId,
42
-            //"ogNym1eye-hVDHjF_laRuxgbli1g",
43
-            //"-8mPKpKQp12wVgmi3767sIb73W0VqM2Oe8dkUUNFako",
44
-            //url,
45
-            //   new
46
-            //   {
47
-            //       first = new { value = first, color = "#173177" },
48
-            //       performance = new { value = "测试地点", color = "#173177" },
49
-            //       time = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), color = "#173177" },
50
-            //       remark = new { value = string.IsNullOrWhiteSpace("") ? "请尽快处理!" : "", color = "#173177" },
51
-            //   });
52
-            //return Success("OK", result);
53
-
54
-            if (string.IsNullOrEmpty(openid)) { openid = "ogNym1TbRgKYcwJrin0qo2W_N2AM"; }
55
-            var url = "http://www.baidu.com";
56
-            var result = await TemplateApi.SendTemplateMessageAsync(AppId, openid, TemplateId, url,
57
-               new
58
-               {
59
-                   first = new { value = "测试发送模板消息!", color = "#173177" },
60
-                   keyword1 = new { value = DateTime.Now.ToString("yyyyMMddHHmmssfff"), color = "#173177" },
61
-                   keyword2 = new { value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), color = "#173177" },
62
-                   remark = new { value = "测试消息内容!", color = "#173177" }
63
-               });
64
-            return Success("OK", result);
65
-        }
66
-
67
-        /// <summary>
68
-        /// 发送模板消息【需要安全验证】
69
-        /// </summary>
70
-        /// <returns></returns>
71
-        [HttpPost("sendtemplatemessage")]
72
-        public async Task<IActionResult> SendTemplateMessageAsync(string openid,  string url, string jsondata, string templateid)
73
-        {
74
-            if (string.IsNullOrEmpty(templateid))
75
-            {
76
-                templateid = TemplateId;
77
-            }
78
-            if (MessageUrl.IndexOf("?") != -1)
79
-            {
80
-                url = MessageUrl + "&" + url;
81
-            }
82
-            else
83
-            {
84
-                url = MessageUrl + "?" + url;
85
-            }
86
-
87
-            var result = await TemplateApi.SendTemplateMessageAsync(AppId, openid, templateid, url, jsondata.ToJObject());
88
-            return Success("OK", result);
89
-        }
90
-
91
-
92
-        /// <summary>
93
-        /// 获取已添加至帐号下所有模板列表
94
-        /// </summary>
95
-        /// <returns></returns>
96
-        public async Task<IActionResult> GetListAsync()
97
-        {
98
-            var result = await TemplateApi.GetPrivateTemplateAsync(AppId);
99
-            return Success("ok", result);
100
-        }
101
-
102
-        /// <summary>
103
-        /// 获取所有模板列表
104
-        /// </summary>
105
-        /// <returns></returns>
106
-        public async Task<IActionResult> AddTemplatesync(string templateno)
107
-        {
108
-            var result = await TemplateApi.AddtemplateAsync(AppId, templateno);
109
-            return Success("ok", result);
110
-        }
111
-
112
-        /// <summary>
113
-        /// 删除模板
114
-        /// </summary>
115
-        /// <returns></returns>
116
-        public async Task<IActionResult> DelTemplatesync(string templateid)
117
-        {
118
-            var result = await TemplateApi.DelPrivateTemplateAsync(AppId, templateid);
119
-            return Success("ok", result);
120
-        }
121
-    }
122
-}

+ 0 - 100
MadRunFabric.WechatApi/WechatApi/Controllers/ValuesController.cs

@@ -1,100 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using Microsoft.AspNetCore.Mvc;
6
-using Microsoft.Extensions.Configuration;
7
-using Microsoft.AspNetCore.Authorization;
8
-using Microsoft.Extensions.Caching.Distributed;
9
-using Api.SignToken;
10
-using Microsoft.Extensions.Logging;
11
-using MadRunFabric.Common;
12
-
13
-namespace SignTokenApi.Controllers
14
-{
15
-    [Authorize]
16
-    [Route("api/[controller]")]
17
-    public class ValuesController : BaseController
18
-    {
19
-
20
-        private readonly IConfiguration _configuration;
21
-        private readonly IDistributedCache _cache;
22
-        private static IPermissionService _permissionService;
23
-        private readonly ILogger<ValuesController> _logger;
24
-
25
-        public ValuesController(IConfiguration configuration, IDistributedCache cache, IPermissionService permissionService, ILogger<ValuesController> logger)
26
-        {
27
-            _configuration = configuration;
28
-            _cache = cache;
29
-            _permissionService = permissionService;
30
-            _logger = logger;
31
-        }
32
-
33
-        [HttpGet("auth")]
34
-        //[PermissionFilter(Permissions.UserUpdate, _permissionService.GetPermissionAsync().Result.ToObject<List<Permission>>())]
35
-        [PermissionFilter(Operations.UserUpdate)]
36
-        public IActionResult Auth()
37
-        {
38
-            _cache.SetStringAsync("name", System.DateTime.Now.ToString());
39
-
40
-            return new JsonResult(new
41
-            {
42
-                Status = false,
43
-                Message = "认证失败1111111111111111111111111111111111"
44
-            });
45
-        }
46
-
47
-
48
-        [AllowAnonymous]
49
-        [HttpGet("getpermission")]
50
-        public string GetPermission()
51
-        {
52
-            var permission = new List<Permission> {
53
-                              new Permission {  Type="User.Create", Name="system"},
54
-                              new Permission {  Type="User.Read", Name="system"}
55
-                          };
56
-            return permission.ToJson();
57
-        }
58
-
59
-        // GET api/values
60
-        [AllowAnonymous]
61
-        [HttpGet]
62
-        public IEnumerable<string> Get()
63
-        {
64
-            return new string[] { "value1", "option1 = 打滴滴" };
65
-        }
66
-
67
-        [HttpGet("get5")]
68
-        public IEnumerable<string> Get5()
69
-        {
70
-            return Get();
71
-        }
72
-
73
-
74
-
75
-        //// GET api/values/5
76
-        //[HttpGet("{id}")]
77
-        //public string Get(int id)
78
-        //{
79
-        //    return "value";
80
-        //}
81
-
82
-        // POST api/values
83
-        [HttpPost]
84
-        public void Post([FromBody]string value)
85
-        {
86
-        }
87
-
88
-        // PUT api/values/5
89
-        [HttpPut("{id}")]
90
-        public void Put(int id, [FromBody]string value)
91
-        {
92
-        }
93
-
94
-        // DELETE api/values/5
95
-        [HttpDelete("{id}")]
96
-        public void Delete(int id)
97
-        {
98
-        }
99
-    }
100
-}

+ 0 - 183
MadRunFabric.WechatApi/WechatApi/Controllers/traffic/AnalysisController.cs

@@ -1,183 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Security.Claims;
5
-using System.Threading.Tasks;
6
-using MadRunFabric.Common;
7
-using Microsoft.AspNetCore.Mvc;
8
-using Microsoft.Extensions.Logging;
9
-using WechatApi.IRepositories;
10
-
11
-namespace WechatApi.Controllers.traffic
12
-{
13
-    [ApiVersion("6.0")]
14
-    [Produces("application/json")]
15
-    [Route("api/[controller]")]
16
-    public class AnalysisController : BaseController
17
-    {
18
-        private readonly ILogger<AnalysisController> _logger;
19
-        private readonly ICall_RecordsRepository _call_recordsRepository;
20
-        private readonly ISys_User_AccountRepository _sys_user_accountRepository;
21
-
22
-        public AnalysisController(ILogger<AnalysisController> logger, ICall_RecordsRepository call_recordsRepository, ISys_User_AccountRepository sys_user_accountRepository)
23
-        {
24
-            _sys_user_accountRepository = sys_user_accountRepository;
25
-            _call_recordsRepository = call_recordsRepository;
26
-            _logger = logger;
27
-        }
28
-        [HttpGet("view")]
29
-        public IActionResult view()
30
-        {
31
-            return Success("成功");
32
-        }
33
-        /// <summary>
34
-        /// 读取话务统计
35
-        /// </summary>
36
-        /// <param name="datetype">0当天、1本周、2本月、3本年、4累计时间</param>
37
-        /// <param name="isself"></param>
38
-        /// <returns></returns>
39
-        [HttpGet("getstatistics")]
40
-        public IActionResult GetStatisticsAsync(int datetype,string usercode)
41
-        {
42
-            string nowusercode = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
43
-            string starttime = string.Empty;
44
-            string etime = string.Empty;
45
-            GetStartEndTime(datetype, out starttime, out etime);
46
-            string agentcode = "";
47
-            if (!string.IsNullOrWhiteSpace(usercode))
48
-                agentcode = usercode;
49
-            else
50
-                agentcode = nowusercode;
51
-
52
-            #region  呼入呼出情况
53
-            string ccount = GetHighChartData(starttime, etime, "", "", agentcode);//总次数
54
-            string cjcount = GetHighChartData(starttime, etime, "", "1", agentcode);//总接通次数
55
-            string cicount = GetHighChartData(starttime, etime, "0", "", agentcode);//呼入次数
56
-            string cijcount = GetHighChartData(starttime, etime, "0", "1", agentcode);//呼入接通次数
57
-            string cocount = GetHighChartData(starttime, etime, "1", "", agentcode);//呼出次数
58
-            string cojcount = GetHighChartData(starttime, etime, "1", "1", agentcode);//呼出接通次数
59
-            string clongs = GetCallRecordTotalTime(agentcode,starttime, etime, "", "1");//总通话时长
60
-            string cilongs = GetCallRecordTotalTime(agentcode, starttime, etime, "0", "1");//呼入通话时长
61
-            string colongs = GetCallRecordTotalTime(agentcode, starttime, etime, "1", "1");//呼出通话时长
62
-            #endregion
63
-            var obj24 = Get24HourCall(starttime, etime, agentcode);//24小时话务情况
64
-            //var agentstate = GetAgentState(starttime, etime, agentcode);//综合数据分析
65
-            var obj = new
66
-            {
67
-                call = new
68
-                {//总话务
69
-                    count = ccount,
70
-                    jtcount = cjcount,
71
-                    talklongs = clongs,
72
-                },
73
-                callin = new
74
-                {//呼入
75
-                    count = cicount,
76
-                    jtcount = cijcount,
77
-                    talklongs = cilongs,
78
-                },
79
-                callout = new
80
-                {//呼出
81
-                    count = cocount,
82
-                    jtcount = cojcount,
83
-                    talklongs = colongs,
84
-                },
85
-                hour24 = obj24,
86
-               // allstate = agentstate,
87
-            };
88
-            return Success("获取话务统计", obj);
89
-        }
90
-        /// <summary>
91
-        /// 获取当天、本周、本月、本年、累计时间
92
-        /// </summary>
93
-        /// <param name="datetype"></param>
94
-        /// <param name="start"></param>
95
-        /// <param name="end"></param>
96
-        public void GetStartEndTime(int datetype, out string start, out string end)
97
-        {
98
-            start = string.Empty;
99
-            end = string.Empty;
100
-
101
-            var datenow = DateTime.Now;
102
-            var datestart = datenow;
103
-            var dateend = datenow;
104
-            switch (datetype)
105
-            {
106
-                case 0://当天
107
-                    break;
108
-                case 1://本周
109
-                    int n = (int)datenow.DayOfWeek == 0 ? 7 : (int)datenow.DayOfWeek;
110
-                    datestart = datenow.AddDays(1 - n);//本周周一
111
-                    dateend = datestart.AddDays(6);//本周周日
112
-                    break;
113
-                case 2://本月
114
-
115
-                    datestart = datenow.AddDays(1 - datenow.Day);  //本月月初  
116
-                    dateend = datestart.AddMonths(1).AddDays(-1);  //本月月末  
117
-                    break;
118
-                case 3://本年
119
-                    datestart = new DateTime(datenow.Year, 1, 1);  //本年年初  
120
-                    dateend = new DateTime(datenow.Year, 12, 31);  //本年年末  
121
-                    break;
122
-                case 4://全部
123
-                    break;
124
-                default:
125
-                    break;
126
-            }
127
-            if (datetype != 4)
128
-            {
129
-                start = datestart.ToString("yyyy-MM-dd") + " 00:00:00";
130
-                end = dateend.ToString("yyyy-MM-dd") + " 23:59:59";
131
-            }
132
-        }
133
-        #region 获取通话量和时长
134
-        /// <summary>
135
-        /// 获取通话时长
136
-        /// </summary>
137
-        /// <param name="agentcode">坐席工号</param>
138
-        /// <param name="BeginTime">开始时间</param>
139
-        /// <param name="EndTime">结束时间</param>
140
-        /// <param name="tag">呼叫类型</param>
141
-        /// <param name="state">呼叫状态</param>
142
-        private string GetCallRecordTotalTime(string agentcode, string BeginTime, string EndTime, string tag, string state)
143
-        {
144
-            var x = _call_recordsRepository.GetCallRecordTotalTime(agentcode, tag, BeginTime, EndTime, state).ToString();
145
-            int i = x.IndexOf(",") + 1;
146
-            return x.Substring(i, x.Length - i);
147
-        }
148
-        /// <summary>
149
-        /// 获取通话量
150
-        /// </summary>
151
-        /// <param name="agentcode">坐席工号</param>
152
-        /// <param name="BeginTime">开始时间</param>
153
-        /// <param name="EndTime">结束时间</param>
154
-        /// <param name="tag">呼叫类型</param>
155
-        /// <param name="state">呼叫状态</param>
156
-        private string GetHighChartData(string BeginTime, string EndTime, string tag, string state, string agentcode)
157
-        {
158
-            var x = _call_recordsRepository.GetHighChartData(agentcode, BeginTime, EndTime, tag, state).ToString();
159
-
160
-            return x;
161
-        }
162
-        /// <summary>
163
-        /// 获取24小时通话情况
164
-        /// </summary>
165
-        /// <param name="agentcode">坐席工号</param>
166
-        /// <param name="BeginTime">开始时间</param>
167
-        /// <param name="EndTime">结束时间</param>
168
-        /// <param name="tag">呼叫类型</param>
169
-        /// <param name="state">呼叫状态</param>
170
-        private object Get24HourCall(string BeginTime, string EndTime, string agentcode)
171
-        {
172
-            var x = _call_recordsRepository.GetHW24CountReport(agentcode, BeginTime, EndTime);
173
-            
174
-            return x;
175
-        }
176
-        private object GetAgentState(string BeginTime, string EndTime, string agentcode)
177
-        {
178
-            var x = _call_recordsRepository.GetAgentState(agentcode, BeginTime, EndTime);
179
-            return x;
180
-        }
181
-        #endregion
182
-    }
183
-}

+ 0 - 232
MadRunFabric.WechatApi/WechatApi/CryptCode/Cryptography.cs

@@ -1,232 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Security.Cryptography;
6
-using System.IO;
7
-using System.Net;
8
-namespace WechatApi.CryptCode
9
-{
10
-    public class Cryptography
11
-    {
12
-        public static UInt32 HostToNetworkOrder(UInt32 inval)
13
-        {
14
-            UInt32 outval = 0;
15
-            for (int i = 0; i < 4; i++)
16
-                outval = (outval << 8) + ((inval >> (i * 8)) & 255);
17
-            return outval;
18
-        }
19
-
20
-        public static Int32 HostToNetworkOrder(Int32 inval)
21
-        {
22
-            Int32 outval = 0;
23
-            for (int i = 0; i < 4; i++)
24
-                outval = (outval << 8) + ((inval >> (i * 8)) & 255);
25
-            return outval;
26
-        }
27
-        /// <summary>
28
-        /// 解密方法
29
-        /// </summary>
30
-        /// <param name="Input">密文</param>
31
-        /// <param name="EncodingAESKey"></param>
32
-        /// <returns></returns>
33
-        /// 
34
-        public static string AES_decrypt(String Input, string EncodingAESKey, ref string appid)
35
-        {
36
-            byte[] Key;
37
-            Key = Convert.FromBase64String(EncodingAESKey + "=");
38
-            byte[] Iv = new byte[16];
39
-            Array.Copy(Key, Iv, 16);
40
-            byte[] btmpMsg = AES_decrypt(Input, Iv, Key);
41
-
42
-            int len = BitConverter.ToInt32(btmpMsg, 16);
43
-            len = IPAddress.NetworkToHostOrder(len);
44
-
45
-
46
-            byte[] bMsg = new byte[len];
47
-            byte[] bAppid = new byte[btmpMsg.Length - 20 - len];
48
-            Array.Copy(btmpMsg, 20, bMsg, 0, len);
49
-            Array.Copy(btmpMsg, 20 + len, bAppid, 0, btmpMsg.Length - 20 - len);
50
-            string oriMsg = Encoding.UTF8.GetString(bMsg);
51
-            appid = Encoding.UTF8.GetString(bAppid);
52
-
53
-
54
-            return oriMsg;
55
-        }
56
-
57
-        public static String AES_encrypt(String Input, string EncodingAESKey, string appid)
58
-        {
59
-            byte[] Key;
60
-            Key = Convert.FromBase64String(EncodingAESKey + "=");
61
-            byte[] Iv = new byte[16];
62
-            Array.Copy(Key, Iv, 16);
63
-            string Randcode = CreateRandCode(16);
64
-            byte[] bRand = Encoding.UTF8.GetBytes(Randcode);
65
-            byte[] bAppid = Encoding.UTF8.GetBytes(appid);
66
-            byte[] btmpMsg = Encoding.UTF8.GetBytes(Input);
67
-            byte[] bMsgLen = BitConverter.GetBytes(HostToNetworkOrder(btmpMsg.Length));
68
-            byte[] bMsg = new byte[bRand.Length + bMsgLen.Length + bAppid.Length + btmpMsg.Length];
69
-
70
-            Array.Copy(bRand, bMsg, bRand.Length);
71
-            Array.Copy(bMsgLen, 0, bMsg, bRand.Length, bMsgLen.Length);
72
-            Array.Copy(btmpMsg, 0, bMsg, bRand.Length + bMsgLen.Length, btmpMsg.Length);
73
-            Array.Copy(bAppid, 0, bMsg, bRand.Length + bMsgLen.Length + btmpMsg.Length, bAppid.Length);
74
-
75
-            return AES_encrypt(bMsg, Iv, Key);
76
-
77
-        }
78
-        private static string CreateRandCode(int codeLen)
79
-        {
80
-            string codeSerial = "2,3,4,5,6,7,a,c,d,e,f,h,i,j,k,m,n,p,r,s,t,A,C,D,E,F,G,H,J,K,M,N,P,Q,R,S,U,V,W,X,Y,Z";
81
-            if (codeLen == 0)
82
-            {
83
-                codeLen = 16;
84
-            }
85
-            string[] arr = codeSerial.Split(',');
86
-            string code = "";
87
-            int randValue = -1;
88
-            Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
89
-            for (int i = 0; i < codeLen; i++)
90
-            {
91
-                randValue = rand.Next(0, arr.Length - 1);
92
-                code += arr[randValue];
93
-            }
94
-            return code;
95
-        }
96
-
97
-        private static String AES_encrypt(String Input, byte[] Iv, byte[] Key)
98
-        {
99
-            var aes = new RijndaelManaged();
100
-            //秘钥的大小,以位为单位
101
-            aes.KeySize = 256;
102
-            //支持的块大小
103
-            aes.BlockSize = 128;
104
-            //填充模式
105
-            aes.Padding = PaddingMode.PKCS7;
106
-            aes.Mode = CipherMode.CBC;
107
-            aes.Key = Key;
108
-            aes.IV = Iv;
109
-            var encrypt = aes.CreateEncryptor(aes.Key, aes.IV);
110
-            byte[] xBuff = null;
111
-
112
-            using (var ms = new MemoryStream())
113
-            {
114
-                using (var cs = new CryptoStream(ms, encrypt, CryptoStreamMode.Write))
115
-                {
116
-                    byte[] xXml = Encoding.UTF8.GetBytes(Input);
117
-                    cs.Write(xXml, 0, xXml.Length);
118
-                }
119
-                xBuff = ms.ToArray();
120
-            }
121
-            String Output = Convert.ToBase64String(xBuff);
122
-            return Output;
123
-        }
124
-
125
-        private static String AES_encrypt(byte[] Input, byte[] Iv, byte[] Key)
126
-        {
127
-            var aes = new RijndaelManaged();
128
-            //秘钥的大小,以位为单位
129
-            aes.KeySize = 256;
130
-            //支持的块大小
131
-            aes.BlockSize = 128;
132
-            //填充模式
133
-            //aes.Padding = PaddingMode.PKCS7;
134
-            aes.Padding = PaddingMode.None;
135
-            aes.Mode = CipherMode.CBC;
136
-            aes.Key = Key;
137
-            aes.IV = Iv;
138
-            var encrypt = aes.CreateEncryptor(aes.Key, aes.IV);
139
-            byte[] xBuff = null;
140
-
141
-            #region 自己进行PKCS7补位,用系统自己带的不行
142
-            byte[] msg = new byte[Input.Length + 32 - Input.Length % 32];
143
-            Array.Copy(Input, msg, Input.Length);
144
-            byte[] pad = KCS7Encoder(Input.Length);
145
-            Array.Copy(pad, 0, msg, Input.Length, pad.Length);
146
-            #endregion
147
-
148
-            #region 注释的也是一种方法,效果一样
149
-            //ICryptoTransform transform = aes.CreateEncryptor();
150
-            //byte[] xBuff = transform.TransformFinalBlock(msg, 0, msg.Length);
151
-            #endregion
152
-
153
-            using (var ms = new MemoryStream())
154
-            {
155
-                using (var cs = new CryptoStream(ms, encrypt, CryptoStreamMode.Write))
156
-                {
157
-                    cs.Write(msg, 0, msg.Length);
158
-                }
159
-                xBuff = ms.ToArray();
160
-            }
161
-
162
-            String Output = Convert.ToBase64String(xBuff);
163
-            return Output;
164
-        }
165
-
166
-        private static byte[] KCS7Encoder(int text_length)
167
-        {
168
-            int block_size = 32;
169
-            // 计算需要填充的位数
170
-            int amount_to_pad = block_size - (text_length % block_size);
171
-            if (amount_to_pad == 0)
172
-            {
173
-                amount_to_pad = block_size;
174
-            }
175
-            // 获得补位所用的字符
176
-            char pad_chr = chr(amount_to_pad);
177
-            string tmp = "";
178
-            for (int index = 0; index < amount_to_pad; index++)
179
-            {
180
-                tmp += pad_chr;
181
-            }
182
-            return Encoding.UTF8.GetBytes(tmp);
183
-        }
184
-        /**
185
-         * 将数字转化成ASCII码对应的字符,用于对明文进行补码
186
-         * 
187
-         * @param a 需要转化的数字
188
-         * @return 转化得到的字符
189
-         */
190
-        static char chr(int a)
191
-        {
192
-
193
-            byte target = (byte)(a & 0xFF);
194
-            return (char)target;
195
-        }
196
-        private static byte[] AES_decrypt(String Input, byte[] Iv, byte[] Key)
197
-        {
198
-            RijndaelManaged aes = new RijndaelManaged();
199
-            aes.KeySize = 256;
200
-            aes.BlockSize = 128;
201
-            aes.Mode = CipherMode.CBC;
202
-            aes.Padding = PaddingMode.None;
203
-            aes.Key = Key;
204
-            aes.IV = Iv;
205
-            var decrypt = aes.CreateDecryptor(aes.Key, aes.IV);
206
-            byte[] xBuff = null;
207
-            using (var ms = new MemoryStream())
208
-            {
209
-                using (var cs = new CryptoStream(ms, decrypt, CryptoStreamMode.Write))
210
-                {
211
-                    byte[] xXml = Convert.FromBase64String(Input);
212
-                    byte[] msg = new byte[xXml.Length + 32 - xXml.Length % 32];
213
-                    Array.Copy(xXml, msg, xXml.Length);
214
-                    cs.Write(xXml, 0, xXml.Length);
215
-                }
216
-                xBuff = decode2(ms.ToArray());
217
-            }
218
-            return xBuff;
219
-        }
220
-        private static byte[] decode2(byte[] decrypted)
221
-        {
222
-            int pad = (int)decrypted[decrypted.Length - 1];
223
-            if (pad < 1 || pad > 32)
224
-            {
225
-                pad = 0;
226
-            }
227
-            byte[] res = new byte[decrypted.Length - pad];
228
-            Array.Copy(decrypted, 0, res, 0, decrypted.Length - pad);
229
-            return res;
230
-        }
231
-    }
232
-}

+ 0 - 221
MadRunFabric.WechatApi/WechatApi/CryptCode/WXBizMsgCrypt.cs

@@ -1,221 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Text;
5
-using System.Xml;
6
-using System.Collections;
7
-//using System.Web;
8
-using System.Security.Cryptography;
9
-//-40001 : 签名验证错误
10
-//-40002 :  xml解析失败
11
-//-40003 :  sha加密生成签名失败
12
-//-40004 :  AESKey 非法
13
-//-40005 :  appid 校验错误
14
-//-40006 :  AES 加密失败
15
-//-40007 : AES 解密失败
16
-//-40008 : 解密后得到的buffer非法
17
-//-40009 :  base64加密异常
18
-//-40010 :  base64解密异常
19
-namespace WechatApi.CryptCode
20
-{
21
-    public class WXBizMsgCrypt
22
-    {
23
-        string m_sToken;
24
-        string m_sEncodingAESKey;
25
-        string m_sAppID;
26
-        enum WXBizMsgCryptErrorCode
27
-        {
28
-            WXBizMsgCrypt_OK = 0,
29
-            WXBizMsgCrypt_ValidateSignature_Error = -40001,
30
-            WXBizMsgCrypt_ParseXml_Error = -40002,
31
-            WXBizMsgCrypt_ComputeSignature_Error = -40003,
32
-            WXBizMsgCrypt_IllegalAesKey = -40004,
33
-            WXBizMsgCrypt_ValidateAppid_Error = -40005,
34
-            WXBizMsgCrypt_EncryptAES_Error = -40006,
35
-            WXBizMsgCrypt_DecryptAES_Error = -40007,
36
-            WXBizMsgCrypt_IllegalBuffer = -40008,
37
-            WXBizMsgCrypt_EncodeBase64_Error = -40009,
38
-            WXBizMsgCrypt_DecodeBase64_Error = -40010
39
-        };
40
-
41
-        //构造函数
42
-        // @param sToken: 公众平台上,开发者设置的Token
43
-        // @param sEncodingAESKey: 公众平台上,开发者设置的EncodingAESKey
44
-        // @param sAppID: 公众帐号的appid
45
-        public WXBizMsgCrypt(string sToken, string sEncodingAESKey, string sAppID)
46
-        {
47
-            m_sToken = sToken;
48
-            m_sAppID = sAppID;
49
-            m_sEncodingAESKey = sEncodingAESKey;
50
-        }
51
-
52
-
53
-        // 检验消息的真实性,并且获取解密后的明文
54
-        // @param sMsgSignature: 签名串,对应URL参数的msg_signature
55
-        // @param sTimeStamp: 时间戳,对应URL参数的timestamp
56
-        // @param sNonce: 随机串,对应URL参数的nonce
57
-        // @param sPostData: 密文,对应POST请求的数据
58
-        // @param sMsg: 解密后的原文,当return返回0时有效
59
-        // @return: 成功0,失败返回对应的错误码
60
-        public int DecryptMsg(string sMsgSignature, string sTimeStamp, string sNonce, string sPostData, ref string sMsg)
61
-        {
62
-            if (m_sEncodingAESKey.Length != 43)
63
-            {
64
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_IllegalAesKey;
65
-            }
66
-            XmlDocument doc = new XmlDocument();
67
-            XmlNode root;
68
-            string sEncryptMsg;
69
-            try
70
-            {
71
-                doc.LoadXml(sPostData);
72
-                root = doc.FirstChild;
73
-                sEncryptMsg = root["Encrypt"].InnerText;
74
-            }
75
-            catch (Exception)
76
-            {
77
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_ParseXml_Error;
78
-            }
79
-            //verify signature
80
-            int ret = 0;
81
-            ret = VerifySignature(m_sToken, sTimeStamp, sNonce, sEncryptMsg, sMsgSignature);
82
-            if (ret != 0)
83
-                return ret;
84
-            //decrypt
85
-            string cpid = "";
86
-            try
87
-            {
88
-                sMsg = Cryptography.AES_decrypt(sEncryptMsg, m_sEncodingAESKey, ref cpid);
89
-            }
90
-            catch (FormatException)
91
-            {
92
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_DecodeBase64_Error;
93
-            }
94
-            catch (Exception)
95
-            {
96
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_DecryptAES_Error;
97
-            }
98
-            if (cpid != m_sAppID)
99
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_ValidateAppid_Error;
100
-            return 0;
101
-        }
102
-
103
-        //将企业号回复用户的消息加密打包
104
-        // @param sReplyMsg: 企业号待回复用户的消息,xml格式的字符串
105
-        // @param sTimeStamp: 时间戳,可以自己生成,也可以用URL参数的timestamp
106
-        // @param sNonce: 随机串,可以自己生成,也可以用URL参数的nonce
107
-        // @param sEncryptMsg: 加密后的可以直接回复用户的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串,
108
-        //						当return返回0时有效
109
-        // return:成功0,失败返回对应的错误码
110
-        public int EncryptMsg(string sReplyMsg, string sTimeStamp, string sNonce, ref string sEncryptMsg)
111
-        {
112
-            if (m_sEncodingAESKey.Length != 43)
113
-            {
114
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_IllegalAesKey;
115
-            }
116
-            string raw = "";
117
-            try
118
-            {
119
-                raw = Cryptography.AES_encrypt(sReplyMsg, m_sEncodingAESKey, m_sAppID);
120
-            }
121
-            catch (Exception)
122
-            {
123
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_EncryptAES_Error;
124
-            }
125
-            string MsgSigature = "";
126
-            int ret = 0;
127
-            ret = GenarateSinature(m_sToken, sTimeStamp, sNonce, raw, ref MsgSigature);
128
-            if (0 != ret)
129
-                return ret;
130
-            sEncryptMsg = "";
131
-
132
-            string EncryptLabelHead = "<Encrypt><![CDATA[";
133
-            string EncryptLabelTail = "]]></Encrypt>";
134
-            string MsgSigLabelHead = "<MsgSignature><![CDATA[";
135
-            string MsgSigLabelTail = "]]></MsgSignature>";
136
-            string TimeStampLabelHead = "<TimeStamp><![CDATA[";
137
-            string TimeStampLabelTail = "]]></TimeStamp>";
138
-            string NonceLabelHead = "<Nonce><![CDATA[";
139
-            string NonceLabelTail = "]]></Nonce>";
140
-            sEncryptMsg = sEncryptMsg + "<xml>" + EncryptLabelHead + raw + EncryptLabelTail;
141
-            sEncryptMsg = sEncryptMsg + MsgSigLabelHead + MsgSigature + MsgSigLabelTail;
142
-            sEncryptMsg = sEncryptMsg + TimeStampLabelHead + sTimeStamp + TimeStampLabelTail;
143
-            sEncryptMsg = sEncryptMsg + NonceLabelHead + sNonce + NonceLabelTail;
144
-            sEncryptMsg += "</xml>";
145
-            return 0;
146
-        }
147
-
148
-        public class DictionarySort : System.Collections.IComparer
149
-        {
150
-            public int Compare(object oLeft, object oRight)
151
-            {
152
-                string sLeft = oLeft as string;
153
-                string sRight = oRight as string;
154
-                int iLeftLength = sLeft.Length;
155
-                int iRightLength = sRight.Length;
156
-                int index = 0;
157
-                while (index < iLeftLength && index < iRightLength)
158
-                {
159
-                    if (sLeft[index] < sRight[index])
160
-                        return -1;
161
-                    else if (sLeft[index] > sRight[index])
162
-                        return 1;
163
-                    else
164
-                        index++;
165
-                }
166
-                return iLeftLength - iRightLength;
167
-
168
-            }
169
-        }
170
-        //Verify Signature
171
-        private static int VerifySignature(string sToken, string sTimeStamp, string sNonce, string sMsgEncrypt, string sSigture)
172
-        {
173
-            string hash = "";
174
-            int ret = 0;
175
-            ret = GenarateSinature(sToken, sTimeStamp, sNonce, sMsgEncrypt, ref hash);
176
-            if (ret != 0)
177
-                return ret;
178
-            //System.Console.WriteLine(hash);
179
-            if (hash == sSigture)
180
-                return 0;
181
-            else
182
-            {
183
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_ValidateSignature_Error;
184
-            }
185
-        }
186
-
187
-        public static int GenarateSinature(string sToken, string sTimeStamp, string sNonce, string sMsgEncrypt, ref string sMsgSignature)
188
-        {
189
-            ArrayList AL = new ArrayList();
190
-            AL.Add(sToken);
191
-            AL.Add(sTimeStamp);
192
-            AL.Add(sNonce);
193
-            AL.Add(sMsgEncrypt);
194
-            AL.Sort(new DictionarySort());
195
-            string raw = "";
196
-            for (int i = 0; i < AL.Count; ++i)
197
-            {
198
-                raw += AL[i];
199
-            }
200
-
201
-            SHA1 sha;
202
-            ASCIIEncoding enc;
203
-            string hash = "";
204
-            try
205
-            {
206
-                sha = new SHA1CryptoServiceProvider();
207
-                enc = new ASCIIEncoding();
208
-                byte[] dataToHash = enc.GetBytes(raw);
209
-                byte[] dataHashed = sha.ComputeHash(dataToHash);
210
-                hash = BitConverter.ToString(dataHashed).Replace("-", "");
211
-                hash = hash.ToLower();
212
-            }
213
-            catch (Exception)
214
-            {
215
-                return (int)WXBizMsgCryptErrorCode.WXBizMsgCrypt_ComputeSignature_Error;
216
-            }
217
-            sMsgSignature = hash;
218
-            return 0;
219
-        }
220
-    }
221
-}

+ 0 - 111
MadRunFabric.WechatApi/WechatApi/MessageHanders/CustomMessageHandler.cs

@@ -1,111 +0,0 @@
1
-
2
-using Api.SignToken;
3
-using MadRunFabric.Common;
4
-using Microsoft.Extensions.Configuration;
5
-using Senparc.Weixin.Context;
6
-using Senparc.Weixin.MP.Entities;
7
-using Senparc.Weixin.MP.Entities.Request;
8
-using Senparc.Weixin.MP.MessageHandlers;
9
-using System;
10
-using System.IO;
11
-
12
-namespace WechatApi.MessageHandlers
13
-{
14
-    public partial class CustomMessageHandler : MessageHandler<MessageContext<IRequestMessageBase, IResponseMessageBase>>
15
-    {
16
-        public readonly ISignTokenService _signTokenService;
17
-        public readonly IConfiguration _configuration;
18
-        public CustomMessageHandler(Stream inputStream, PostModel postModel, IConfiguration configuration, ISignTokenService signTokenService) : base(inputStream, postModel)
19
-        {
20
-            _signTokenService = signTokenService;
21
-            _configuration = configuration;
22
-        }
23
-
24
-        /// <summary>
25
-        /// 订阅事件
26
-        /// </summary>
27
-        /// <param name="requestMessage"></param>
28
-        /// <returns></returns>
29
-        public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage)
30
-        {
31
-            if (!string.IsNullOrEmpty(requestMessage.EventKey))
32
-            {
33
-                string eventkey = requestMessage.EventKey;
34
-                string usercode = eventkey.Replace("qrscene_", "");
35
-                string title = "绑定账号成功!";
36
-                string result = _signTokenService.Wechat_BindAsync(usercode, requestMessage.FromUserName).Result;
37
-                if (result.ToJObject()["state"].ToString() != "success")
38
-                {
39
-                    title = "绑定账号失败!";
40
-                }
41
-                var responseMessage = base.CreateResponseMessage<ResponseMessageNews>();
42
-                var art = new Article();
43
-                art.Title = title;
44
-                art.Description = "账号:" + usercode + "\n时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
45
-                responseMessage.Articles.Add(art);
46
-                return responseMessage;
47
-            }
48
-            else
49
-            {
50
-                //var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
51
-                //responseMessage.Content = "你好,欢迎关注NuodaMaintenance!";
52
-                //return responseMessage;
53
-
54
-                var responseMessage = base.CreateResponseMessage<ResponseMessageNews>();
55
-                var json = _configuration["WechatStatic:SubscribeJson"];
56
-                responseMessage.Articles = json.ToList<Article>();
57
-                return responseMessage;
58
-            }
59
-        }
60
-
61
-        /// <summary>
62
-        /// 扫描事件
63
-        /// </summary>
64
-        /// <param name="requestMessage"></param>
65
-        /// <returns></returns>
66
-        public override IResponseMessageBase OnEvent_ScanRequest(RequestMessageEvent_Scan requestMessage)
67
-        {
68
-            if (!string.IsNullOrEmpty(requestMessage.EventKey))
69
-            {
70
-                string usercode = requestMessage.EventKey;
71
-                string title = "绑定账号成功!";
72
-                string result = _signTokenService.Wechat_BindAsync(usercode, requestMessage.FromUserName).Result;
73
-                if (result.ToJObject()["state"].ToString() != "success")
74
-                {
75
-                    title = "绑定账号失败!";
76
-                }
77
-
78
-                var responseMessage = base.CreateResponseMessage<ResponseMessageNews>();
79
-                var art = new Article();
80
-                art.Title = title;
81
-                art.Description = "账号:" + usercode + "\n时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
82
-                responseMessage.Articles.Add(art);
83
-                return responseMessage;
84
-            }
85
-            else
86
-            {
87
-                //var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
88
-                //responseMessage.Content = "你好,欢迎扫描关注NuodaMaintenance!";
89
-                //return responseMessage;
90
-
91
-                var responseMessage = base.CreateResponseMessage<ResponseMessageNews>();
92
-                var json = _configuration["WechatStatic:SubscribeJson"];
93
-                responseMessage.Articles = json.ToList<Article>();
94
-                return responseMessage;
95
-            }
96
-        }
97
-
98
-        /// <summary>
99
-        /// 默认回复
100
-        /// </summary>
101
-        /// <param name="requestMessage"></param>
102
-        /// <returns></returns>
103
-        public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage)
104
-        {
105
-            var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
106
-            responseMessage.Content = "欢迎你!";
107
-            return responseMessage;
108
-        }
109
-    }
110
-
111
-}

+ 0 - 19
MadRunFabric.WechatApi/WechatApi/Model/LocationInput.cs

@@ -1,19 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-
6
-namespace WechatApi.Model
7
-{
8
-    public class LocationInput
9
-    {
10
-        /// <summary>
11
-        /// 经度
12
-        /// </summary>
13
-        public string Longitude { get; set; } = "";
14
-        /// <summary>
15
-        /// 纬度
16
-        /// </summary>
17
-        public string Latitude { get; set; } = "";
18
-    }
19
-}

+ 0 - 17
MadRunFabric.WechatApi/WechatApi/Model/MenuInput.cs

@@ -1,17 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-
6
-namespace WechatApi.Model
7
-{
8
-    public class MenuButton
9
-    {
10
-        public string Name { get; set; } = "";
11
-        public string Key { get; set; } = "";
12
-        public string Type { get; set; } = "click";
13
-        public string Url { get; set; } = "";
14
-
15
-        public List<MenuButton> sub_button { get; set; } = new List<MenuButton>();
16
-    }
17
-}

+ 0 - 15
MadRunFabric.WechatApi/WechatApi/Model/TemplateSendDto.cs

@@ -1,15 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-
6
-namespace WechatApi.Model
7
-{
8
-    public class TemplateSendDto
9
-    {
10
-        public int WechatId { get; set; }
11
-        public int UserId { get; set; }
12
-        public List<string> Data { get; set; }
13
-
14
-    }
15
-}

+ 0 - 13
MadRunFabric.WechatApi/WechatApi/Model/WorkOrderInput.cs

@@ -1,13 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-
6
-namespace WechatApi.Model
7
-{
8
-    public class WorkOrderInput
9
-    {
10
-        public string Code { get; set; }
11
-
12
-    }
13
-}

+ 0 - 32
MadRunFabric.WechatApi/WechatApi/Program.cs

@@ -1,32 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.IO;
4
-using System.Linq;
5
-using System.Threading.Tasks;
6
-using Microsoft.AspNetCore;
7
-using Microsoft.AspNetCore.Hosting;
8
-using Microsoft.Extensions.Configuration;
9
-using Microsoft.Extensions.Logging;
10
-using MongoDB.Bson;
11
-using MongoDB.Bson.Serialization;
12
-using MongoDB.Bson.Serialization.Serializers;
13
-
14
-namespace SignTokenApi
15
-{
16
-    public class Program
17
-    {
18
-        public static void Main(string[] args)
19
-        {
20
-            var serializer = new DateTimeSerializer(DateTimeKind.Local, BsonType.DateTime);
21
-            BsonSerializer.RegisterSerializer(typeof(DateTime), serializer);
22
-
23
-            BuildWebHost(args).Run();
24
-        }
25
-
26
-        public static IWebHost BuildWebHost(string[] args) =>
27
-            WebHost.CreateDefaultBuilder(args)
28
-                .UseStartup<Startup>()
29
-                .UseUrls("http://*:28260")
30
-                .Build();
31
-    }
32
-}

+ 0 - 47
MadRunFabric.WechatApi/WechatApi/Properties/launchSettings.json

@@ -1,47 +0,0 @@
1
-{
2
-  "iisSettings": {
3
-    "windowsAuthentication": false,
4
-    "anonymousAuthentication": true,
5
-    "iisExpress": {
6
-      "applicationUrl": "http://localhost:53069/",
7
-      "sslPort": 0
8
-    }
9
-  },
10
-  "profiles": {
11
-    "IIS Express": {
12
-      "commandName": "IISExpress",
13
-      "launchBrowser": true,
14
-      "launchUrl": "api/info",
15
-      "environmentVariables": {
16
-        "ASPNETCORE_ENVIRONMENT": "Development"
17
-      }
18
-    },
19
-    "WechatApi(Dev)": {
20
-      "commandName": "Project",
21
-      "launchBrowser": false,
22
-      "launchUrl": "api/info",
23
-      "environmentVariables": {
24
-        "ASPNETCORE_ENVIRONMENT": "Development_Test"
25
-      },
26
-      "applicationUrl": "http://localhost:28260/"
27
-    },
28
-    "WechatApi(DevBase)": {
29
-      "commandName": "Project",
30
-      "launchBrowser": false,
31
-      "launchUrl": "api/info",
32
-      "environmentVariables": {
33
-        "ASPNETCORE_ENVIRONMENT": "Development_Base"
34
-      },
35
-      "applicationUrl": "http://localhost:28260/"
36
-    },
37
-    "WechatApi(Prod)": {
38
-      "commandName": "Project",
39
-      "launchBrowser": false,
40
-      "launchUrl": "api/info",
41
-      "environmentVariables": {
42
-        "ASPNETCORE_ENVIRONMENT": "Production"
43
-      },
44
-      "applicationUrl": "http://localhost:28260/"
45
-    }
46
-  }
47
-}

+ 0 - 213
MadRunFabric.WechatApi/WechatApi/Startup.cs

@@ -1,213 +0,0 @@
1
-using System;
2
-using System.Collections.Generic;
3
-using System.Linq;
4
-using System.Threading.Tasks;
5
-using Microsoft.AspNetCore.Builder;
6
-using Microsoft.AspNetCore.Hosting;
7
-using Microsoft.Extensions.Configuration;
8
-using Microsoft.Extensions.DependencyInjection;
9
-using Microsoft.Extensions.Logging;
10
-using Microsoft.Extensions.Options;
11
-using Microsoft.AspNetCore.Authorization;
12
-using Api.SignToken;
13
-using Microsoft.IdentityModel.Tokens;
14
-using System.Text;
15
-using System.Security.Claims;
16
-using Microsoft.AspNetCore.Authentication.JwtBearer;
17
-using System.IdentityModel.Tokens.Jwt;
18
-using Pivotal.Discovery.Client;
19
-using NLog.Extensions.Logging;
20
-using NLog.Web;
21
-using Microsoft.AspNetCore.Mvc.Versioning;
22
-using MadRunFabric.Common.Options;
23
-using AutoMapper;
24
-using Senparc.Weixin.MP.Containers;
25
-using WechatApi.IRepositories;
26
-using WechatApi.Repositories;
27
-using MadRunFabric.Common;
28
-
29
-namespace SignTokenApi
30
-{
31
-    public class Startup
32
-    {
33
-        private readonly string AppId;
34
-        private readonly string AppSecret;
35
-        public Startup(IHostingEnvironment env)
36
-        {
37
-            Configuration = new ConfigurationBuilder()
38
-                            .SetBasePath(env.ContentRootPath)
39
-                            .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
40
-                            .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true)
41
-                            .AddEnvironmentVariables()
42
-                            .Build();
43
-
44
-            AppId = Configuration["WechatStatic:AppId"];
45
-            AppSecret = Configuration["WechatStatic:AppSecret"];
46
-        }
47
-
48
-        public IConfiguration Configuration { get; }
49
-
50
-        // This method gets called by the runtime. Use this method to add services to the container.
51
-        public void ConfigureServices(IServiceCollection services)
52
-        {
53
-            #region Cors 配置
54
-            //生产环境 的cors
55
-            services.AddCors(options =>
56
-            {
57
-                options.AddPolicy("CorsProd",
58
-                 builder => builder.AllowAnyOrigin()
59
-                //builder => builder.WithOrigins(Configuration["Cors"].Split(','))
60
-                .AllowAnyMethod()
61
-                .AllowAnyHeader()
62
-                .AllowCredentials().SetPreflightMaxAge(TimeSpan.FromMinutes(30)));
63
-            });
64
-            //开发环境的cors
65
-            services.AddCors(options =>
66
-            {
67
-                options.AddPolicy("CorsDev",
68
-                builder => builder.AllowAnyOrigin()
69
-                .AllowAnyMethod()
70
-                .AllowAnyHeader()
71
-                .AllowCredentials().SetPreflightMaxAge(TimeSpan.FromMinutes(30)));
72
-            });
73
-            #endregion
74
-
75
-            #region 授权配置
76
-            //读取jwt配置文件
77
-            var signingKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:SecretKey"].ToString()));
78
-            var tokenValidationParameters = new TokenValidationParameters
79
-            {
80
-                ValidateIssuerSigningKey = true,
81
-                IssuerSigningKey = signingKey,
82
-                ValidateIssuer = true,
83
-                ValidIssuer = Configuration["Jwt:Issuer"].ToString(),//发行人
84
-                ValidateAudience = true,
85
-                ValidAudience = Configuration["Jwt:Audience"].ToString(),//订阅人
86
-                ValidateLifetime = true,
87
-                ClockSkew = TimeSpan.Zero,
88
-                RequireExpirationTime = true,
89
-            };
90
-
91
-            services.AddAuthentication(options =>
92
-            {
93
-                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
94
-                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
95
-            })
96
-            .AddJwtBearer(o =>
97
-            {
98
-                o.RequireHttpsMetadata = false;
99
-                o.TokenValidationParameters = tokenValidationParameters;
100
-                o.Events = new JwtBearerEvents
101
-                {
102
-                    OnTokenValidated = context =>
103
-                    {
104
-                        if (context.Request.Path.Value.ToString() == "/api/logout")
105
-                        {
106
-                            var token = ((context as TokenValidatedContext).SecurityToken as JwtSecurityToken).RawData;
107
-                        }
108
-                        return Task.CompletedTask;
109
-                    }
110
-                };
111
-            });
112
-            #endregion
113
-
114
-            #region redis配置
115
-            services.AddDistributedRedisCache(options =>
116
-            {
117
-                options.InstanceName = Configuration["Redis:InstanceName"].ToString();
118
-                options.Configuration = $"{Configuration["Redis:HostName"].ToString()}:{Configuration["Redis:Port"].ToString()},allowAdmin=true,password={Configuration["Redis:Password"].ToString()},defaultdatabase={Configuration["Redis:Defaultdatabase"].ToString()}";
119
-            });
120
-            #endregion
121
-
122
-            services.AddSingleton<IConfiguration>(Configuration);
123
-
124
-            //注入授权Handler
125
-            services.AddSingleton<IAuthorizationHandler, PermissionAuthorizationHandler>();
126
-
127
-            services.AddSingleton<IPermissionService, PermissionService>();
128
-            services.AddSingleton<ISignTokenService, SignTokenService>();
129
-
130
-            #region 版本控制
131
-            services.AddApiVersioning(Options =>
132
-            {
133
-                Options.ReportApiVersions = true;//可选,为true API返回响应标头中支持的版本信息
134
-                Options.ApiVersionReader = new QueryStringApiVersionReader(parameterName: "api-version");
135
-                Options.AssumeDefaultVersionWhenUnspecified = true;
136
-                Options.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(6, 0);
137
-            });
138
-            #endregion
139
-
140
-
141
-            #region AutoMapper
142
-            services.AddAutoMapper();
143
-            #endregion
144
-
145
-            services.AddMvc(options =>
146
-            {
147
-                options.Filters.Add<ActionFilter>();
148
-                options.Filters.Add(new ExceptionFilter());
149
-            }).AddJsonOptions(op => op.SerializerSettings.ContractResolver =
150
-                                        new Newtonsoft.Json.Serialization.DefaultContractResolver());
151
-
152
-            #region Mongodb配置
153
-            services.Configure<MongodbOptions>(options =>
154
-            {
155
-                options.ConnectionString = Configuration.GetSection("MongoConnection:ConnectionString").Value;
156
-                options.Database = Configuration.GetSection("MongoConnection:Database").Value;
157
-            });
158
-            #endregion
159
-
160
-
161
-            #region 添加仓储访问服务
162
-            services.AddTransient<ILocationRepository, LocationRepository>();
163
-            services.AddTransient<ICall_RecordsRepository, Call_RecordsRepository>();
164
-            services.AddTransient<ISys_User_AccountRepository, Sys_User_AccountRepository>();
165
-            
166
-            #endregion
167
-
168
-
169
-            #region steeltoe
170
-            services.AddDiscoveryClient(Configuration);
171
-            #endregion
172
-
173
-
174
-
175
-
176
-        }
177
-
178
-        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
179
-        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
180
-        {
181
-            if (env.IsProduction())
182
-            {
183
-                app.UseCors("CorsProd");
184
-            }
185
-            else
186
-            {
187
-                app.UseCors("CorsDev");
188
-                app.UseDeveloperExceptionPage();
189
-                app.UseDatabaseErrorPage();
190
-                app.UseBrowserLink();
191
-            }
192
-
193
-            app.UseAuthentication();
194
-
195
-            app.UseMvc();
196
-            app.UseStaticFiles();
197
-
198
-            #region steeltoe
199
-            app.UseDiscoveryClient();
200
-            #endregion
201
-
202
-            #region Nlog 引入
203
-            loggerFactory.AddNLog();//添加NLog
204
-            env.ConfigureNLog("nlog.config");//读取Nlog配置文件
205
-            app.AddNLogWeb();
206
-            #endregion
207
-
208
-            #region 注册微信AccessTokenContainer
209
-            AccessTokenContainer.Register(AppId, AppSecret);
210
-            #endregion
211
-        }
212
-    }
213
-}

+ 0 - 40
MadRunFabric.WechatApi/WechatApi/WechatApi.csproj

@@ -1,40 +0,0 @@
1
-<Project Sdk="Microsoft.NET.Sdk.Web">
2
-
3
-  <PropertyGroup>
4
-    <TargetFramework>netcoreapp2.0</TargetFramework>
5
-    <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
6
-    <UserSecretsId>815f9cbf-f3c5-4c5a-b98e-da4a83876bbf</UserSecretsId>
7
-  </PropertyGroup>
8
-
9
-  <ItemGroup>
10
-    <Compile Remove="Controllers\ValuesController.cs" />
11
-  </ItemGroup>
12
-
13
-  <ItemGroup>
14
-    <PackageReference Include="AutoMapper" Version="6.2.2" />
15
-    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
16
-    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
17
-    <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.1.0" />
18
-    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.3" />
19
-    <PackageReference Include="MongoDB.Driver" Version="2.5.0" />
20
-    <PackageReference Include="NLog.Web.AspNetCore" Version="4.4.1" />
21
-    <PackageReference Include="Pivotal.Discovery.Client" Version="1.1.0" />
22
-    <PackageReference Include="Senparc.Weixin" Version="4.20.2" />
23
-    <PackageReference Include="Senparc.Weixin.MP" Version="14.12.2" />
24
-    <PackageReference Include="Senparc.Weixin.MP.MVC" Version="5.2.0" />
25
-  </ItemGroup>
26
-
27
-  <ItemGroup>
28
-    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
29
-  </ItemGroup>
30
-
31
-  <ItemGroup>
32
-    <ProjectReference Include="..\..\Api.SignToken\Api.SignToken.csproj" />
33
-    <ProjectReference Include="..\..\MadRunFabirc.Model\MadRunFabric.Model.csproj" />
34
-    <ProjectReference Include="..\..\MadRunFabric.Common\MadRunFabric.Common.csproj" />
35
-    <ProjectReference Include="..\WechatApi.IRepositories\WechatApi.IRepositories.csproj" />
36
-    <ProjectReference Include="..\WechatApi.Model\WechatApi.Model.csproj" />
37
-    <ProjectReference Include="..\WechatApi.Repositories\WechatApi.Repositories.csproj" />
38
-  </ItemGroup>
39
-
40
-</Project>

+ 0 - 79
MadRunFabric.WechatApi/WechatApi/appsettings.Development.json

@@ -1,79 +0,0 @@
1
-{
2
-  "Cors": "",
3
-  "Logging": {
4
-    "IncludeScopes": false,
5
-    "LogLevel": {
6
-      "Default": "Debug",
7
-      "System": "Error",
8
-      "Microsoft": "Error",
9
-      "Steeltoe": "Error"
10
-    }
11
-  },
12
-  "Jwt": {
13
-    "Issuer": "HySignToken",
14
-    "Audience": "HyCallCenterApi",
15
-    "SecretKey": "HYBambooJIe256sdkDfjiTSkjienTGjnVcu85114udfhbudgdkfUh"
16
-  },
17
-  "MongoConnection": {
18
-    //"ConnectionString": "mongodb://root:123456@192.168.5.44:27017",
19
-    //"Database": "madrunfabricdb"
20
-    "ConnectionString": "mongodb://root:123456@192.168.5.44:27017", //本机
21
-    "Database": "yh"
22
-  },
23
-  "Redis": {
24
-    "HostName": "192.168.5.44",
25
-    "Port": "6379",
26
-    "Password": "",
27
-    "Defaultdatabase": "5",
28
-    "InstanceName": "wechat"
29
-  },
30
-  "spring": {
31
-    "application": {
32
-      "name": "wechatapi"
33
-    }
34
-  },
35
-  "location": {
36
-    "url": "https://apis.map.qq.com/ws/geocoder/v1/",
37
-    "key": "26KBZ-YBJRO-3RPWW-SUEYL-K2KKQ-BTBYL",
38
-    "poi": 0
39
-  },
40
-  //----------------------------微信配置------------------------------------------------------------
41
-  "WechatStatic": {
42
-    "AppId": "111111111111111111",
43
-    "AppSecret": "111111111111111111111111",
44
-    "Token": "E406A2BBDEC463A497E41B1AB0FD7290",
45
-    "EncodingAESKey": "wlUch5ogf03ozrN4mWE0e5CMTDTAFFo4Ghop55n0b1q",
46
-    "MenuJson": "[{\"Name\":\"快速下单\",\"Key\":\"KSXD\",\"Type\":\"view\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXSM\"},{\"Name\":\"订单查询\",\"Key\":\"DDCX\",\"Type\":\"view\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXCX\"}]",
47
-    "QRCodeTimeOut": "1800",
48
-    "MchId": "", //商户号
49
-    "TenPayV3Notify": "", //商户回调地址
50
-    "Key": "", //api秘钥
51
-    "MessageUrl": "http://weixin.nuodajituan.com/index.html", //消息跳转url
52
-    "TemplateId": "pnzxZuc4GuJzexVGlwLvNb01cFSHKSB-YXicdrzLzb4",
53
-    //"FocusUrl": "https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzU4NDQ4MjQzMg==&scene=124#wechat_redirect" //关注url
54
-    "SubscribeJson": "[{\"Title\":\"快速报修,请点上图\",\"Description\":\"\",\"PicUrl\":\"http://122.114.109.238:28000/fileserverapi/api/Upload/1A3B42D2A8211C53F33019D310C9ABB1D8041E46AEDA6B8704105EC941E81CF1901956AFCBA2D212A1621C18B2759E0258990304B85278F87F9D6DD8EFB72B2F58E24FD7600DC221CB247B7E733750FEA97C19CB5CA7B33A19FA933E99D1720EE641BD7C5DE8237F57EAE2F43E48D09D1F35A1C73EEB86E4ADA14E1E23C42F84\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXSM\"}]"
55
-  },
56
-  //----------------------------APP推送定位信息配置------------------------------------------------------------
57
-  "AppSendLocationTimespan": "30",
58
-  "eureka": {
59
-    "client": {
60
-      "serviceUrl": "http://192.168.5.46:28100/eureka/"
61
-      //"shouldFetchRegistry": false
62
-    },
63
-    "instance": {
64
-      "preferIpAddress": true,
65
-      //服务过期时间配置,
66
-      //超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除 #注意,EurekaServer一定要设置eureka.server.eviction-interval-timer-in-ms否则这个配置无效,这个配置一般为服务刷新时间配置的三倍
67
-      //默认90s 在删除实例之前,EurekaServer等待的时间,默认= 90秒
68
-      "leaseExpirationDurationInSeconds": 15,
69
-      //服务刷新时间配置,每隔这个时间会主动心跳一次
70
-      //默认30s 客户端需要发送心跳的频率,默认值= 30s
71
-      "leaseRenewalIntervalInSeconds": 5,
72
-      "statusPageUrlPath": "/api/info",
73
-      "port": 28260
74
-      // Remove comments to enable SSL requests
75
-      // More changes in Program.cs are required if using direct C2C communications
76
-      //,"securePortEnabled": true
77
-    }
78
-  }
79
-}

+ 0 - 79
MadRunFabric.WechatApi/WechatApi/appsettings.Development_Base.json

@@ -1,79 +0,0 @@
1
-{
2
-  "Cors": "",
3
-  "Logging": {
4
-    "IncludeScopes": false,
5
-    "LogLevel": {
6
-      "Default": "Debug",
7
-      "System": "Error",
8
-      "Microsoft": "Error",
9
-      "Steeltoe": "Error"
10
-    }
11
-  },
12
-  "Jwt": {
13
-    "Issuer": "HySignToken",
14
-    "Audience": "HyCallCenterApi",
15
-    "SecretKey": "HYBambooJIe256sdkDfjiTSkjienTGjnVcu85114udfhbudgdkfUh"
16
-  },
17
-  "MongoConnection": {
18
-    //"ConnectionString": "mongodb://root:123456@192.168.5.44:27017",
19
-    //"Database": "madrunfabricdb_base"
20
-    "ConnectionString": "mongodb://root:123456@192.168.5.44:27017", //本机
21
-    "Database": "yh"
22
-  },
23
-  "Redis": {
24
-    "HostName": "192.168.5.44",
25
-    "Port": "6379",
26
-    "Password": "",
27
-    "Defaultdatabase": "5",
28
-    "InstanceName": "wechat"
29
-  },
30
-  "spring": {
31
-    "application": {
32
-      "name": "wechatapi"
33
-    }
34
-  },
35
-  "location": {
36
-    "url": "https://apis.map.qq.com/ws/geocoder/v1/",
37
-    "key": "26KBZ-YBJRO-3RPWW-SUEYL-K2KKQ-BTBYL",
38
-    "poi": 0
39
-  },
40
-  //----------------------------微信配置------------------------------------------------------------
41
-  "WechatStatic": {
42
-    "AppId": "wxe03366d8c63d9b09",
43
-    "AppSecret": "3e42313935a4d6dc8b450172b8be2765",
44
-    "Token": "",
45
-    "EncodingAESKey": "",
46
-    "MenuJson": "[{\"Name\":\"快速下单\",\"Key\":\"KSXD\",\"Type\":\"view\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXSM\"},{\"Name\":\"订单查询\",\"Key\":\"DDCX\",\"Type\":\"view\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXCX\"}]",
47
-    "QRCodeTimeOut": "1800",
48
-    "MchId": "", //商户号
49
-    "TenPayV3Notify": "", //商户回调地址
50
-    "Key": "", //api秘钥
51
-    "MessageUrl": "http://weixin.nuodajituan.com/index.html", //消息跳转url
52
-    "TemplateId": "XIKstNS_OuqDOENZuYghKIMp7dr0Namzk_THyZfQZOs",
53
-    //"FocusUrl": "https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzIxNDczMTgxNg==&scene=124#wechat_redirect", //关注url
54
-    "SubscribeJson": "[{\"Title\":\"\",\"Description\":\"快速报修,请点上图\",\"PicUrl\":\"http://122.114.109.238:28000/fileserverapi/api/Upload/1A3B42D2A8211C53F33019D310C9ABB1D8041E46AEDA6B8704105EC941E81CF179A971C3CF7D9F059F8E29ABC58E4954109F61781F227D40C4F583F749517526EFFC88CA9337398FD604438C6965452B6315D91982C36650C34FA7B7C605804D1108377ED13DB54DCC6D2296B3C9A081\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXSM\"}]"
55
-  },
56
-  //----------------------------APP推送配置------------------------------------------------------------
57
-  "AppSendLocationTimespan": "30",
58
-  "eureka": {
59
-    "client": {
60
-      "serviceUrl": "http://192.168.5.42:28100/eureka/"
61
-      //"shouldFetchRegistry": false
62
-    },
63
-    "instance": {
64
-      "preferIpAddress": true,
65
-      //服务过期时间配置,
66
-      //超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除 #注意,EurekaServer一定要设置eureka.server.eviction-interval-timer-in-ms否则这个配置无效,这个配置一般为服务刷新时间配置的三倍
67
-      //默认90s 在删除实例之前,EurekaServer等待的时间,默认= 90秒
68
-      "leaseExpirationDurationInSeconds": 15,
69
-      //服务刷新时间配置,每隔这个时间会主动心跳一次
70
-      //默认30s 客户端需要发送心跳的频率,默认值= 30s
71
-      "leaseRenewalIntervalInSeconds": 5,
72
-      "statusPageUrlPath": "/api/info",
73
-      "port": 28260
74
-      // Remove comments to enable SSL requests
75
-      // More changes in Program.cs are required if using direct C2C communications
76
-      //,"securePortEnabled": true
77
-    }
78
-  }
79
-}

+ 0 - 79
MadRunFabric.WechatApi/WechatApi/appsettings.Development_Test.json

@@ -1,79 +0,0 @@
1
-{
2
-  "Cors": "",
3
-  "Logging": {
4
-    "IncludeScopes": false,
5
-    "LogLevel": {
6
-      "Default": "Debug",
7
-      "System": "Error",
8
-      "Microsoft": "Error",
9
-      "Steeltoe": "Error"
10
-    }
11
-  },
12
-  "Jwt": {
13
-    "Issuer": "HySignToken",
14
-    "Audience": "HyCallCenterApi",
15
-    "SecretKey": "HYBambooJIe256sdkDfjiTSkjienTGjnVcu85114udfhbudgdkfUh"
16
-  },
17
-  "MongoConnection": {
18
-    //"ConnectionString": "mongodb://root:123456@192.168.5.44:27017",
19
-    //"Database": "madrunfabricdb"
20
-    "ConnectionString": "mongodb://root:123456@192.168.5.44:27017", //本机
21
-    "Database": "yh"
22
-  },
23
-  "Redis": {
24
-    "HostName": "192.168.5.44",
25
-    "Port": "6379",
26
-    "Password": "",
27
-    "Defaultdatabase": "5",
28
-    "InstanceName": "wechat"
29
-  },
30
-  "spring": {
31
-    "application": {
32
-      "name": "wechatapi"
33
-    }
34
-  },
35
-  "location": {
36
-    "url": "https://apis.map.qq.com/ws/geocoder/v1/",
37
-    "key": "26KBZ-YBJRO-3RPWW-SUEYL-K2KKQ-BTBYL",
38
-    "poi": 0
39
-  },
40
-  //----------------------------微信配置------------------------------------------------------------
41
-  "WechatStatic": {
42
-    "AppId": "111111111111111111",
43
-    "AppSecret": "111111111111111111111111",
44
-    "Token": "E406A2BBDEC463A497E41B1AB0FD7290",
45
-    "EncodingAESKey": "wlUch5ogf03ozrN4mWE0e5CMTDTAFFo4Ghop55n0b1q",
46
-    "MenuJson": "[{\"Name\":\"快速下单\",\"Key\":\"KSXD\",\"Type\":\"view\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXSM\"},{\"Name\":\"订单查询\",\"Key\":\"DDCX\",\"Type\":\"view\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXCX\"}]",
47
-    "QRCodeTimeOut": "1800",
48
-    "MchId": "", //商户号
49
-    "TenPayV3Notify": "", //商户回调地址
50
-    "Key": "", //api秘钥
51
-    "MessageUrl": "http://weixin.nuodajituan.com/index.html", //消息跳转url
52
-    "TemplateId": "pnzxZuc4GuJzexVGlwLvNb01cFSHKSB-YXicdrzLzb4",
53
-    //"FocusUrl": "https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzU4NDQ4MjQzMg==&scene=124#wechat_redirect" //关注url
54
-    "SubscribeJson": "[{\"Title\":\"快速报修,请点上图\",\"Description\":\"\",\"PicUrl\":\"http://122.114.109.238:28000/fileserverapi/api/Upload/1A3B42D2A8211C53F33019D310C9ABB1D8041E46AEDA6B8704105EC941E81CF1901956AFCBA2D212A1621C18B2759E0258990304B85278F87F9D6DD8EFB72B2F58E24FD7600DC221CB247B7E733750FEA97C19CB5CA7B33A19FA933E99D1720EE641BD7C5DE8237F57EAE2F43E48D09D1F35A1C73EEB86E4ADA14E1E23C42F84\",\"Url\":\"http://weixin.nuodajituan.com/index.html?menucode=WXSM\"}]"
55
-  },
56
-  //----------------------------APP推送定位信息配置------------------------------------------------------------
57
-  "AppSendLocationTimespan": "30",
58
-  "eureka": {
59
-    "client": {
60
-      "serviceUrl": "http://192.168.5.46:28100/eureka/"
61
-      //"shouldFetchRegistry": false
62
-    },
63
-    "instance": {
64
-      "preferIpAddress": true,
65
-      //服务过期时间配置,
66
-      //超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除 #注意,EurekaServer一定要设置eureka.server.eviction-interval-timer-in-ms否则这个配置无效,这个配置一般为服务刷新时间配置的三倍
67
-      //默认90s 在删除实例之前,EurekaServer等待的时间,默认= 90秒
68
-      "leaseExpirationDurationInSeconds": 15,
69
-      //服务刷新时间配置,每隔这个时间会主动心跳一次
70
-      //默认30s 客户端需要发送心跳的频率,默认值= 30s
71
-      "leaseRenewalIntervalInSeconds": 5,
72
-      "statusPageUrlPath": "/api/info",
73
-      "port": 28260
74
-      // Remove comments to enable SSL requests
75
-      // More changes in Program.cs are required if using direct C2C communications
76
-      //,"securePortEnabled": true
77
-    }
78
-  }
79
-}

+ 0 - 80
MadRunFabric.WechatApi/WechatApi/appsettings.Production.json

@@ -1,80 +0,0 @@
1
-{
2
-  "Cors": "",
3
-  "Logging": {
4
-    "IncludeScopes": false,
5
-    "LogLevel": {
6
-      "Default": "Debug",
7
-      "System": "Error",
8
-      "Microsoft": "Error",
9
-      "Steeltoe": "Error"
10
-    }
11
-  },
12
-  "Jwt": {
13
-    "Issuer": "HySignToken",
14
-    "Audience": "HyCallCenterApi",
15
-    "SecretKey": "HYBambooJIe256sdkDfjiTSkjienTGjnVcu85114udfhbudgdkfUh"
16
-  },
17
-  "MongoConnection": {
18
-    //"ConnectionString": "mongodb://root:hykj800100@10.125.7.246:37017",
19
-    //"Database": "madrunfabricdb"
20
-    "ConnectionString": "mongodb://root:123456@192.168.5.44:27017", //本机
21
-    "Database": "yh"
22
-  },
23
-  "Redis": {
24
-    "HostName": "10.125.7.246",
25
-    "Port": "6379",
26
-    "Password": "hykj800100",
27
-    "Defaultdatabase": "5",
28
-    "InstanceName": "wechat"
29
-  },
30
-  "spring": {
31
-    "application": {
32
-      "name": "wechatapi"
33
-    }
34
-  },
35
-  "location": {
36
-    "url": "https://apis.map.qq.com/ws/geocoder/v1/",
37
-    "key": "26KBZ-YBJRO-3RPWW-SUEYL-K2KKQ-BTBYL",
38
-    "poi": 0
39
-  },
40
-  //----------------------------微信配置------------------------------------------------------------
41
-  "WechatStatic": {
42
-    "AppId": "wx473e2d60365d70b8",
43
-    "AppSecret": "d50b25bb47a0606a0e1a775ebfd51a87",
44
-    "Token": "E406A2BBDEC463A497E41B1AB0FD7290",
45
-    "EncodingAESKey": "wlUch5ogf03ozrN4mWE0e5CMTDTAFFo4Ghop55n0b1q",
46
-    "MenuJson": "[{\"Name\":\"快速下单\",\"Key\":\"KSXD\",\"Type\":\"view\",\"Url\":\"http://wechat.nuodajituan.com/index.html?menucode=WXSM\"},{\"Name\":\"订单查询\",\"Key\":\"DDCX\",\"Type\":\"view\",\"Url\":\"http://wechat.nuodajituan.com/index.html?menucode=WXCX\"}]",
47
-    "QRCodeTimeOut": "1800",
48
-    "MchId": "", //商户号
49
-    "TenPayV3Notify": "", //商户回调地址
50
-    "Key": "", //api秘钥
51
-    "MessageUrl": "http://wechat.nuodajituan.com/index.html", //消息跳转url
52
-    "TemplateId": "pnzxZuc4GuJzexVGlwLvNb01cFSHKSB-YXicdrzLzb4",
53
-    //"FocusUrl": "https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzU4NDQ4MjQzMg==&scene=124#wechat_redirect" //关注url
54
-    "SubscribeJson": "[{\"Title\":\"快速报修,请点上图\",\"Description\":\"\",\"PicUrl\":\"http://122.114.231.155:28000/fileserverapi/api/Upload/1A3B42D2A8211C53F33019D310C9ABB1D8041E46AEDA6B8704105EC941E81CF1901956AFCBA2D212A1621C18B2759E0258990304B85278F87F9D6DD8EFB72B2F58E24FD7600DC221CB247B7E733750FEA97C19CB5CA7B33A19FA933E99D1720EE641BD7C5DE8237F57EAE2F43E48D09D1F35A1C73EEB86E4ADA14E1E23C42F84\",\"Url\":\"http://wechat.nuodajituan.com/index.html?menucode=WXSM\"}]"
55
-  },
56
-  //----------------------------APP推送定位信息配置------------------------------------------------------------
57
-  "AppSendLocationTimespan": "30",
58
-  "eureka": {
59
-    "client": {
60
-      "serviceUrl": "http://10.125.3.223:28100/eureka/"
61
-      //"shouldFetchRegistry": false
62
-    },
63
-    "instance": {
64
-      "ipAddress": "yunwei.nuodajituan.com",
65
-      "preferIpAddress": true,
66
-      //服务过期时间配置,
67
-      //超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除 #注意,EurekaServer一定要设置eureka.server.eviction-interval-timer-in-ms否则这个配置无效,这个配置一般为服务刷新时间配置的三倍
68
-      //默认90s 在删除实例之前,EurekaServer等待的时间,默认= 90秒
69
-      "leaseExpirationDurationInSeconds": 15,
70
-      //服务刷新时间配置,每隔这个时间会主动心跳一次
71
-      //默认30s 客户端需要发送心跳的频率,默认值= 30s
72
-      "leaseRenewalIntervalInSeconds": 5,
73
-      "statusPageUrlPath": "/api/info",
74
-      "port": 28260
75
-      // Remove comments to enable SSL requests
76
-      // More changes in Program.cs are required if using direct C2C communications
77
-      //,"securePortEnabled": true
78
-    }
79
-  }
80
-}

+ 0 - 15
MadRunFabric.WechatApi/WechatApi/appsettings.json

@@ -1,15 +0,0 @@
1
-{
2
-  "Logging": {
3
-    "IncludeScopes": false,
4
-    "Debug": {
5
-      "LogLevel": {
6
-        "Default": "Warning"
7
-      }
8
-    },
9
-    "Console": {
10
-      "LogLevel": {
11
-        "Default": "Warning"
12
-      }
13
-    }
14
-  }
15
-}

+ 0 - 71
MadRunFabric.WechatApi/WechatApi/nlog.config

@@ -1,71 +0,0 @@
1
-<?xml version="1.0" encoding="utf-8" ?>
2
-<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
3
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-      autoReload="true"
5
-      internalLogLevel="Error"
6
-      internalLogFile="nlogtemp\internal-nlog.txt">
7
-
8
- <!-- 加载ASP.NET Core插件 -->
9
-  <extensions>
10
-    <add assembly="NLog.Web.AspNetCore"/>
11
-  </extensions>
12
-
13
-  <!-- 输出目的地 -->
14
-  <targets>
15
-    <!-- 输出到文件,这个文件记录所有日志 -->
16
-    <!--<target xsi:type="File" name="allfile" fileName="\nlogtemp\${shortdate}\nlog-all-${shortdate}.log"
17
-                layout="记录时间:${longdate}|控制器:${logger}|消息:${message} 异常:${exception}" />-->
18
-
19
-    <!-- 另外一个日志记录文件,户口也跳过Microsoft开头相关日志信息 -->
20
-    <!--archiveFileName表示滚动日志存放路径,log.{#####}.txt是滚动日志文件名-->
21
-    <!--archiveAboveSize每个日志文件大小的最大值(单位:字节)20(mb)=20971520(b),主日志文件超过大小超过该值时会将文件内容写入滚动日志并清空主日志文件内容-->
22
-    <!--maxArchiveFiles滚动日志文件上限数,滚动日志文件数达到上限新的文件内容会覆盖旧文件内容 -->
23
-
24
-    <target xsi:type="File" name="own_file" fileName="log/${shortdate}/own_${shortdate}.log"
25
-            archiveFileName="log/${shortdate}/own_${shortdate}.{#####}.log"
26
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false" 
27
-            layout="${level}|记录时间:${longdate}|${event-properties:item=EventId.Id}|控制器:${logger}|action: ${aspnet-mvc-action}|${newline}消息:${message}|${newline}异常:${exception}|${newline}url: ${aspnet-request-url}|${newline}" />
28
-    <!--layout="记录时间:${longdate}|控制器:${logger}|  action: ${aspnet-mvc-action}|  消息:${message} 异常:${exception}" />-->
29
-    <!--错误提示-->
30
-    
31
-
32
-    <target name="error_file" xsi:type="File" fileName="log/${shortdate}/error-${shortdate}.log"
33
-            archiveFileName="log/${shortdate}/own-${shortdate}.{#####}.log"
34
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false" 
35
-            layout="${level}|记录时间:${longdate}|控制器:${logger}|action: ${aspnet-mvc-action}|${newline}消息:${message}|${newline}异常:${onexception:${exception:format=tostring} ${newline} ${stacktrace}|${newline}" />
36
-    <target name="debugger_file" xsi:type="File" fileName="log/${shortdate}/debugger-${shortdate}.log"
37
-            archiveFileName="log/${shortdate}/debugger-${shortdate}.{#####}.log"
38
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false"
39
-            layout="${level}|记录时间:${longdate}|控制器:${logger}|action: ${aspnet-mvc-action}|消息:${message}|${newline}" />
40
-     <target name="warn_file" xsi:type="File" fileName="log/${shortdate}/warn-${shortdate}.log"
41
-            archiveFileName="log/${shortdate}/warn-${shortdate}.{#####}.log"
42
-            archiveAboveSize="20971520" archiveNumbering="Rolling" concurrentWrites="true" maxArchiveFiles="-1" keepFileOpen="false" 
43
-            layout="${level}|记录时间:${longdate}|控制器:${logger}|action: ${aspnet-mvc-action}|消息:${message}|${newline}" />
44
-    <!-- write to the void aka just remove -->
45
-    <target xsi:type="Null" name="blackhole" />
46
-  </targets>
47
-
48
-  <!-- 写入目的地的规则 -->
49
-  <rules>
50
-    <!--全部记录,包括Microsoft开头的相关日志信息-->
51
-    <!--<logger name="*" minlevel="Trace" writeTo="allfile" />-->
52
-
53
-    <!--name - 记录者的名字 (允许使用通配符*)
54
-        minlevel - 匹配日志范围的最低级别
55
-        maxlevel - 匹配日志范围的最高级别
56
-        level - 匹配的单一日志级别 :::::NLog 用于输出日志的级别包括:Trace,Debug,Info,Warn,Error,Fatal
57
-        levels - 匹配的一系列日志级别,由逗号分隔。
58
-        writeTo - 规则匹配时日志应该被写入的一系列目标,由逗号分隔。-->
59
-
60
-    <!--跳过Microsoft开头的相关日志信息-->
61
-    <!--<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />-->
62
-
63
-    <!--错误提示-->
64
-    <logger name="*" minlevel="Trace" writeTo="own_file" />
65
-    <logger name="*" level="Debug" writeTo="debugger_file" />
66
-    <logger name="*" minlevel="Error" writeTo="error_file" />
67
-    <logger name="*" level="Warn" writeTo="warn_file" />
68
- 
69
-
70
-  </rules>
71
-</nlog>