忽略dll文件git
This commit is contained in:
@@ -1,89 +1,89 @@
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
public class ArticleController : MvcBaseController
|
||||
{
|
||||
ArticleService m_ArticleServce;
|
||||
|
||||
public ArticleController(ArticleService _ArticleServce)
|
||||
{
|
||||
m_ArticleServce = _ArticleServce;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Index([FromQuery]ArticleSearchModel request)
|
||||
{
|
||||
request = request ?? new ArticleSearchModel();
|
||||
Expression<Func<ArticleEntity, bool>> exp = m => 1 == 1;
|
||||
if (request.Catalog > 0)
|
||||
{
|
||||
exp = exp.And(m => m.CatalogId == request.Catalog);
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
exp = exp.And(m => m.Title.Contains(request.KeyWord) || m.SubTitle.Contains(request.KeyWord));
|
||||
}
|
||||
|
||||
var ret = await m_ArticleServce.Page(request.PageIndex, request.PageSize, exp);
|
||||
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Search([FromQuery]ArticleSearchModel request)
|
||||
{
|
||||
request = request ?? new ArticleSearchModel();
|
||||
Expression<Func<ArticleEntity, bool>> exp = m => 1 == 1;
|
||||
if (request.Catalog > 0)
|
||||
{
|
||||
exp = exp.And(m => m.CatalogId == request.Catalog);
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
exp = exp.And(m => m.Title.Contains(request.KeyWord) || m.SubTitle.Contains(request.KeyWord));
|
||||
}
|
||||
|
||||
var ret = await m_ArticleServce.Page(request.PageIndex, request.PageSize, exp);
|
||||
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Info(int id)
|
||||
{
|
||||
var prev = await m_ArticleServce.Query(m => m.Id < id).OrderByDescending(m => m.Id).FirstOrDefaultAsync();
|
||||
var ret = await m_ArticleServce.GetById(id);
|
||||
var next = await m_ArticleServce.Query(m => m.Id > id).OrderBy(m => m.Id).FirstOrDefaultAsync();
|
||||
return View(new ArticleInfoMode()
|
||||
{
|
||||
|
||||
Prev = prev,
|
||||
Info = ret,
|
||||
Next = next
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TaoBao()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
public class ArticleController : MvcBaseController
|
||||
{
|
||||
ArticleService m_ArticleServce;
|
||||
|
||||
public ArticleController(ArticleService _ArticleServce)
|
||||
{
|
||||
m_ArticleServce = _ArticleServce;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Index([FromQuery]ArticleSearchModel request)
|
||||
{
|
||||
request = request ?? new ArticleSearchModel();
|
||||
Expression<Func<ArticleEntity, bool>> exp = m => 1 == 1;
|
||||
if (request.Catalog > 0)
|
||||
{
|
||||
exp = exp.And(m => m.CatalogId == request.Catalog);
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
exp = exp.And(m => m.Title.Contains(request.KeyWord) || m.SubTitle.Contains(request.KeyWord));
|
||||
}
|
||||
|
||||
var ret = await m_ArticleServce.Page(request.PageIndex, request.PageSize, exp);
|
||||
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Search([FromQuery]ArticleSearchModel request)
|
||||
{
|
||||
request = request ?? new ArticleSearchModel();
|
||||
Expression<Func<ArticleEntity, bool>> exp = m => 1 == 1;
|
||||
if (request.Catalog > 0)
|
||||
{
|
||||
exp = exp.And(m => m.CatalogId == request.Catalog);
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
exp = exp.And(m => m.Title.Contains(request.KeyWord) || m.SubTitle.Contains(request.KeyWord));
|
||||
}
|
||||
|
||||
var ret = await m_ArticleServce.Page(request.PageIndex, request.PageSize, exp);
|
||||
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Info(int id)
|
||||
{
|
||||
var prev = await m_ArticleServce.Query(m => m.Id < id).OrderByDescending(m => m.Id).FirstOrDefaultAsync();
|
||||
var ret = await m_ArticleServce.GetById(id);
|
||||
var next = await m_ArticleServce.Query(m => m.Id > id).OrderBy(m => m.Id).FirstOrDefaultAsync();
|
||||
return View(new ArticleInfoMode()
|
||||
{
|
||||
|
||||
Prev = prev,
|
||||
Info = ret,
|
||||
Next = next
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TaoBao()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Home.Controllers
|
||||
{
|
||||
|
||||
public class HomeController : MvcBaseController
|
||||
{
|
||||
ProductService m_ProductService;
|
||||
|
||||
ArticleService m_ArticleService;
|
||||
ProductOrderService m_ProductOrderService;
|
||||
|
||||
public HomeController(ProductService _ProductService, ArticleService _ArticleService, ProductOrderService _ProductOrderService)
|
||||
{
|
||||
m_ProductService = _ProductService;
|
||||
m_ArticleService = _ArticleService;
|
||||
m_ProductOrderService = _ProductOrderService;
|
||||
}
|
||||
[Route("/")]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var prodectList=await m_ProductService.Query(m=>m.OnLine==1).ToListAsync();
|
||||
var model = prodectList.MapsTo<ProductModel>();
|
||||
return View(model);
|
||||
}
|
||||
[Route("/h")]
|
||||
public IActionResult Test()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
[Route("/Test1")]
|
||||
public async Task Test1()
|
||||
{
|
||||
await m_ProductOrderService.TestProcessOrderAccount();
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Home.Controllers
|
||||
{
|
||||
|
||||
public class HomeController : MvcBaseController
|
||||
{
|
||||
ProductService m_ProductService;
|
||||
|
||||
ArticleService m_ArticleService;
|
||||
ProductOrderService m_ProductOrderService;
|
||||
|
||||
public HomeController(ProductService _ProductService, ArticleService _ArticleService, ProductOrderService _ProductOrderService)
|
||||
{
|
||||
m_ProductService = _ProductService;
|
||||
m_ArticleService = _ArticleService;
|
||||
m_ProductOrderService = _ProductOrderService;
|
||||
}
|
||||
[Route("/")]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var prodectList=await m_ProductService.Query(m=>m.OnLine==1).ToListAsync();
|
||||
var model = prodectList.MapsTo<ProductModel>();
|
||||
return View(model);
|
||||
}
|
||||
[Route("/h")]
|
||||
public IActionResult Test()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
[Route("/Test1")]
|
||||
public async Task Test1()
|
||||
{
|
||||
await m_ProductOrderService.TestProcessOrderAccount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,141 +1,141 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
public class LineListController : MvcBaseController
|
||||
{
|
||||
|
||||
ProductRouteService m_ProductRouteService;
|
||||
|
||||
ProductService m_ProductService;
|
||||
public LineListController(ProductRouteService _ProductRouteService, ProductService _ProductService)
|
||||
{
|
||||
m_ProductRouteService = _ProductRouteService;
|
||||
m_ProductService = _ProductService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Index([FromQuery]LineSearchModel request)
|
||||
{
|
||||
request = request ?? new LineSearchModel();
|
||||
Expression<Func<ProductRouteEntity, bool>> exp =null;
|
||||
|
||||
if (request.ProductId > 0)
|
||||
{
|
||||
exp = m => m.ProductId == request.ProductId;
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
Expression<Func<ProductRouteEntity, bool>> filterExpr = m =>
|
||||
m.Province.Contains(request.KeyWord)
|
||||
|| m.City.Contains(request.KeyWord)
|
||||
|| m.Name.Contains(request.KeyWord)
|
||||
|| m.ServerUrl.Contains(request.KeyWord);
|
||||
if (exp == null)
|
||||
exp = filterExpr;
|
||||
else exp=exp.And(filterExpr);
|
||||
}
|
||||
|
||||
var ret = await m_ProductRouteService.Query(exp).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
|
||||
var products = await m_ProductService.Query(m=>m.OnLine == 1).OrderBy(m=>m.Sort).ToListAsync();
|
||||
ViewData["products"] = products;
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index2([FromQuery]LineSearchModel request)
|
||||
{
|
||||
request = request ?? new LineSearchModel();
|
||||
Expression<Func<ProductRouteEntity, bool>> exp =null;
|
||||
|
||||
if (request.ProductId > 0)
|
||||
{
|
||||
exp = m => m.ProductId == request.ProductId;
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
Expression<Func<ProductRouteEntity, bool>> filterExpr = m =>
|
||||
m.Province.Contains(request.KeyWord)
|
||||
|| m.City.Contains(request.KeyWord)
|
||||
|| m.Name.Contains(request.KeyWord)
|
||||
|| m.ServerUrl.Contains(request.KeyWord);
|
||||
if (exp == null)
|
||||
exp = filterExpr;
|
||||
else exp=exp.And(filterExpr);
|
||||
}
|
||||
|
||||
var ret = await m_ProductRouteService.Query(exp).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
|
||||
var products = await m_ProductService.Query(m=>m.OnLine == 1).OrderBy(m=>m.Sort).ToListAsync();
|
||||
ViewData["products"] = products;
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Xieyi()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Excel([FromQuery]LineSearchModel request)
|
||||
{
|
||||
request = request ?? new LineSearchModel();
|
||||
Expression<Func<ProductRouteEntity, bool>> exp = m => 1 == 1;
|
||||
|
||||
if (request.ProductId > 0)
|
||||
{
|
||||
exp = exp.And(m => m.ProductId == request.ProductId);
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
exp = exp.Or(m => m.Province.Contains(request.KeyWord));
|
||||
exp = exp.Or(m => m.City.Contains(request.KeyWord));
|
||||
exp = exp.Or(m => m.Name.Contains(request.KeyWord));
|
||||
exp = exp.Or(m => m.KeyWord.Contains(request.KeyWord));
|
||||
}
|
||||
|
||||
var ret = await m_ProductRouteService.Query(exp).ToListAsync();
|
||||
|
||||
var data = new ExcelData<ProductRouteEntity>
|
||||
{
|
||||
SheetName ="线路表",
|
||||
Data = ret
|
||||
};
|
||||
|
||||
var title = new List<ExcelTitle>(){
|
||||
new ExcelTitle { Property = "ProductName", Title = "产品" },
|
||||
new ExcelTitle { Property = "Province", Title = "省份" },
|
||||
new ExcelTitle { Property = "City", Title = "城市" },
|
||||
new ExcelTitle { Property = "Name", Title = "运营商" },
|
||||
new ExcelTitle { Property = "ServerUrl", Title = "服务器" },
|
||||
new ExcelTitle { Property = "BandWidth", Title = "实时带宽" },
|
||||
new ExcelTitle { Property = "IpRemark", Title = "IP量" },
|
||||
new ExcelTitle { Property = "Status", Title = "状态" },
|
||||
};
|
||||
var fileBytes = ExcelHelper.ExportListToExcel(data, title);
|
||||
|
||||
var fileName = $"线路表.xlsx";
|
||||
Response.Headers.Add("X-Suggested-Filename", fileName.UrlEncode());
|
||||
return File(fileBytes, "application/octet-stream", fileName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.Vpn.Domain;
|
||||
using Hncore.Pass.Vpn.Service;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
public class LineListController : MvcBaseController
|
||||
{
|
||||
|
||||
ProductRouteService m_ProductRouteService;
|
||||
|
||||
ProductService m_ProductService;
|
||||
public LineListController(ProductRouteService _ProductRouteService, ProductService _ProductService)
|
||||
{
|
||||
m_ProductRouteService = _ProductRouteService;
|
||||
m_ProductService = _ProductService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Index([FromQuery]LineSearchModel request)
|
||||
{
|
||||
request = request ?? new LineSearchModel();
|
||||
Expression<Func<ProductRouteEntity, bool>> exp =null;
|
||||
|
||||
if (request.ProductId > 0)
|
||||
{
|
||||
exp = m => m.ProductId == request.ProductId;
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
Expression<Func<ProductRouteEntity, bool>> filterExpr = m =>
|
||||
m.Province.Contains(request.KeyWord)
|
||||
|| m.City.Contains(request.KeyWord)
|
||||
|| m.Name.Contains(request.KeyWord)
|
||||
|| m.ServerUrl.Contains(request.KeyWord);
|
||||
if (exp == null)
|
||||
exp = filterExpr;
|
||||
else exp=exp.And(filterExpr);
|
||||
}
|
||||
|
||||
var ret = await m_ProductRouteService.Query(exp).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
|
||||
var products = await m_ProductService.Query(m=>m.OnLine == 1).OrderBy(m=>m.Sort).ToListAsync();
|
||||
ViewData["products"] = products;
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index2([FromQuery]LineSearchModel request)
|
||||
{
|
||||
request = request ?? new LineSearchModel();
|
||||
Expression<Func<ProductRouteEntity, bool>> exp =null;
|
||||
|
||||
if (request.ProductId > 0)
|
||||
{
|
||||
exp = m => m.ProductId == request.ProductId;
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
Expression<Func<ProductRouteEntity, bool>> filterExpr = m =>
|
||||
m.Province.Contains(request.KeyWord)
|
||||
|| m.City.Contains(request.KeyWord)
|
||||
|| m.Name.Contains(request.KeyWord)
|
||||
|| m.ServerUrl.Contains(request.KeyWord);
|
||||
if (exp == null)
|
||||
exp = filterExpr;
|
||||
else exp=exp.And(filterExpr);
|
||||
}
|
||||
|
||||
var ret = await m_ProductRouteService.Query(exp).OrderBy(m=>m.Sort).ToListAsync();
|
||||
|
||||
|
||||
var products = await m_ProductService.Query(m=>m.OnLine == 1).OrderBy(m=>m.Sort).ToListAsync();
|
||||
ViewData["products"] = products;
|
||||
return View(ret);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Xieyi()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Excel([FromQuery]LineSearchModel request)
|
||||
{
|
||||
request = request ?? new LineSearchModel();
|
||||
Expression<Func<ProductRouteEntity, bool>> exp = m => 1 == 1;
|
||||
|
||||
if (request.ProductId > 0)
|
||||
{
|
||||
exp = exp.And(m => m.ProductId == request.ProductId);
|
||||
}
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
exp = exp.Or(m => m.Province.Contains(request.KeyWord));
|
||||
exp = exp.Or(m => m.City.Contains(request.KeyWord));
|
||||
exp = exp.Or(m => m.Name.Contains(request.KeyWord));
|
||||
exp = exp.Or(m => m.KeyWord.Contains(request.KeyWord));
|
||||
}
|
||||
|
||||
var ret = await m_ProductRouteService.Query(exp).ToListAsync();
|
||||
|
||||
var data = new ExcelData<ProductRouteEntity>
|
||||
{
|
||||
SheetName ="线路表",
|
||||
Data = ret
|
||||
};
|
||||
|
||||
var title = new List<ExcelTitle>(){
|
||||
new ExcelTitle { Property = "ProductName", Title = "产品" },
|
||||
new ExcelTitle { Property = "Province", Title = "省份" },
|
||||
new ExcelTitle { Property = "City", Title = "城市" },
|
||||
new ExcelTitle { Property = "Name", Title = "运营商" },
|
||||
new ExcelTitle { Property = "ServerUrl", Title = "服务器" },
|
||||
new ExcelTitle { Property = "BandWidth", Title = "实时带宽" },
|
||||
new ExcelTitle { Property = "IpRemark", Title = "IP量" },
|
||||
new ExcelTitle { Property = "Status", Title = "状态" },
|
||||
};
|
||||
var fileBytes = ExcelHelper.ExportListToExcel(data, title);
|
||||
|
||||
var fileName = $"线路表.xlsx";
|
||||
Response.Headers.Add("X-Suggested-Filename", fileName.UrlEncode());
|
||||
return File(fileBytes, "application/octet-stream", fileName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
[Controller]
|
||||
[AllowAnonymous]
|
||||
[Route("[Controller]/[Action]")]
|
||||
public abstract class MvcBaseController : Controller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
[Controller]
|
||||
[AllowAnonymous]
|
||||
[Route("[Controller]/[Action]")]
|
||||
public abstract class MvcBaseController : Controller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,120 +1,120 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.BaseInfo.Service;
|
||||
using Hncore.Pass.Sells.Service;
|
||||
using Hncore.Wx.Open;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Senparc.NeuChar.App.Entities;
|
||||
using Senparc.Weixin.MP;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
[Controller]
|
||||
[Route("[Controller]/[Action]")]
|
||||
public class WeiXinController : Controller
|
||||
{
|
||||
WxAppUserService m_WxAppUserService;
|
||||
CouponService m_CouponService;
|
||||
IConfiguration m_Configuration;
|
||||
public WeiXinController(IConfiguration _Configuration
|
||||
, WxAppUserService _WxAppUserService
|
||||
, CouponService _CouponService)
|
||||
{
|
||||
m_WxAppUserService = _WxAppUserService;
|
||||
m_CouponService = _CouponService;
|
||||
m_Configuration = _Configuration;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ActionName("Index")]
|
||||
public ActionResult Get(string signature, string timestamp, string nonce, string echostr)
|
||||
{
|
||||
if (CheckSignature.Check(signature, timestamp, nonce, "hualian"))
|
||||
{
|
||||
return Content(echostr); //返回随机字符串则表示验证通过
|
||||
}
|
||||
else
|
||||
{
|
||||
return Content("failed");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最简化的处理流程(不加密)
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[ActionName("Index")]
|
||||
public ActionResult Post(PostModel postModel)
|
||||
{
|
||||
if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, "hualian"))
|
||||
{
|
||||
return Content("参数错误!");
|
||||
}
|
||||
|
||||
postModel.Token ="hualian";
|
||||
postModel.EncodingAESKey = m_Configuration["WxApps:EncodingAESKey"];//根据自己后台的设置保持一致
|
||||
postModel.AppId = m_Configuration["WxApps:AppID"];//根据自己后台的设置保持一致
|
||||
|
||||
|
||||
|
||||
var messageHandler = new MyMessageHandler(Request.Body, m_WxAppUserService,m_CouponService);
|
||||
|
||||
messageHandler.Execute();//执行微信处理过程
|
||||
|
||||
return Content(messageHandler.ResponseDocument.ToString());//v0.7-
|
||||
//return new WeixinResult(messageHandler);//v0.8+
|
||||
// return new FixWeixinBugWeixinResult(messageHandler);//v0.8+
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 微信后台推送过来的用户与公众号交互的信息 消息和事件
|
||||
/// </summary>
|
||||
/// <param name="timestamp"></param>
|
||||
/// <param name="nonce"></param>
|
||||
/// <param name="encrypt_type"></param>
|
||||
/// <param name="msg_signature"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{appid}"), AllowAnonymous]
|
||||
public async Task<string> msg_notice(string appid, string timestamp, string nonce, string encrypt_type, string msg_signature)
|
||||
{
|
||||
LogHelper.Debug("公众号交互消息", $"appid={appid},{timestamp},{nonce},{encrypt_type},{msg_signature}");
|
||||
var msg = await this.Request.Body.ReadAsStringAsync();
|
||||
LogHelper.Debug("公众号交互消息-加密", msg);
|
||||
var token = m_Configuration["WxOpen:Token"];
|
||||
var decyptKey = m_Configuration["WxOpen:DecyptKey"];
|
||||
var appID = m_Configuration["WxOpen:AppID"];
|
||||
string decMsg = "";
|
||||
var wxcpt = new WxOpenCrypt(token, decyptKey, appID);
|
||||
var ret = wxcpt.DecryptMsg(msg_signature, timestamp, nonce, msg, ref decMsg);
|
||||
if (ret != 0)
|
||||
{
|
||||
LogHelper.Error("开放平台推送的消息-解密失败", ret);
|
||||
return "faild";
|
||||
}
|
||||
|
||||
var flag = false;
|
||||
try
|
||||
{
|
||||
var requestMessage = MessageFactory.GetRequestEntity(decMsg);
|
||||
if (requestMessage != null)
|
||||
{
|
||||
requestMessage.AppId = appid;
|
||||
flag = await requestMessage.Handler();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Fatal("微信开放平台的消息-解析失败", ex.Message);
|
||||
LogHelper.Error("开放平台推送的消息-解密的消息", decMsg);
|
||||
flag = false;
|
||||
}
|
||||
return flag ? "success" : "faild";
|
||||
}
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.BaseInfo.Service;
|
||||
using Hncore.Pass.Sells.Service;
|
||||
using Hncore.Wx.Open;
|
||||
using Home.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Senparc.NeuChar.App.Entities;
|
||||
using Senparc.Weixin.MP;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Home.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
[Controller]
|
||||
[Route("[Controller]/[Action]")]
|
||||
public class WeiXinController : Controller
|
||||
{
|
||||
WxAppUserService m_WxAppUserService;
|
||||
CouponService m_CouponService;
|
||||
IConfiguration m_Configuration;
|
||||
public WeiXinController(IConfiguration _Configuration
|
||||
, WxAppUserService _WxAppUserService
|
||||
, CouponService _CouponService)
|
||||
{
|
||||
m_WxAppUserService = _WxAppUserService;
|
||||
m_CouponService = _CouponService;
|
||||
m_Configuration = _Configuration;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ActionName("Index")]
|
||||
public ActionResult Get(string signature, string timestamp, string nonce, string echostr)
|
||||
{
|
||||
if (CheckSignature.Check(signature, timestamp, nonce, "hualian"))
|
||||
{
|
||||
return Content(echostr); //返回随机字符串则表示验证通过
|
||||
}
|
||||
else
|
||||
{
|
||||
return Content("failed");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最简化的处理流程(不加密)
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[ActionName("Index")]
|
||||
public ActionResult Post(PostModel postModel)
|
||||
{
|
||||
if (!CheckSignature.Check(postModel.Signature, postModel.Timestamp, postModel.Nonce, "hualian"))
|
||||
{
|
||||
return Content("参数错误!");
|
||||
}
|
||||
|
||||
postModel.Token ="hualian";
|
||||
postModel.EncodingAESKey = m_Configuration["WxApps:EncodingAESKey"];//根据自己后台的设置保持一致
|
||||
postModel.AppId = m_Configuration["WxApps:AppID"];//根据自己后台的设置保持一致
|
||||
|
||||
|
||||
|
||||
var messageHandler = new MyMessageHandler(Request.Body, m_WxAppUserService,m_CouponService);
|
||||
|
||||
messageHandler.Execute();//执行微信处理过程
|
||||
|
||||
return Content(messageHandler.ResponseDocument.ToString());//v0.7-
|
||||
//return new WeixinResult(messageHandler);//v0.8+
|
||||
// return new FixWeixinBugWeixinResult(messageHandler);//v0.8+
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 微信后台推送过来的用户与公众号交互的信息 消息和事件
|
||||
/// </summary>
|
||||
/// <param name="timestamp"></param>
|
||||
/// <param name="nonce"></param>
|
||||
/// <param name="encrypt_type"></param>
|
||||
/// <param name="msg_signature"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{appid}"), AllowAnonymous]
|
||||
public async Task<string> msg_notice(string appid, string timestamp, string nonce, string encrypt_type, string msg_signature)
|
||||
{
|
||||
LogHelper.Debug("公众号交互消息", $"appid={appid},{timestamp},{nonce},{encrypt_type},{msg_signature}");
|
||||
var msg = await this.Request.Body.ReadAsStringAsync();
|
||||
LogHelper.Debug("公众号交互消息-加密", msg);
|
||||
var token = m_Configuration["WxOpen:Token"];
|
||||
var decyptKey = m_Configuration["WxOpen:DecyptKey"];
|
||||
var appID = m_Configuration["WxOpen:AppID"];
|
||||
string decMsg = "";
|
||||
var wxcpt = new WxOpenCrypt(token, decyptKey, appID);
|
||||
var ret = wxcpt.DecryptMsg(msg_signature, timestamp, nonce, msg, ref decMsg);
|
||||
if (ret != 0)
|
||||
{
|
||||
LogHelper.Error("开放平台推送的消息-解密失败", ret);
|
||||
return "faild";
|
||||
}
|
||||
|
||||
var flag = false;
|
||||
try
|
||||
{
|
||||
var requestMessage = MessageFactory.GetRequestEntity(decMsg);
|
||||
if (requestMessage != null)
|
||||
{
|
||||
requestMessage.AppId = appid;
|
||||
flag = await requestMessage.Handler();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Fatal("微信开放平台的消息-解析失败", ex.Message);
|
||||
LogHelper.Error("开放平台推送的消息-解密的消息", decMsg);
|
||||
flag = false;
|
||||
}
|
||||
return flag ? "success" : "faild";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user