pc登录bug 修复
parent
b421c0df7a
commit
232b97402b
|
|
@ -2,6 +2,7 @@
|
|||
using New_College.Common;
|
||||
using New_College.Common.Helper;
|
||||
using New_College.IServices;
|
||||
using New_College.Services;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Controllers
|
||||
|
|
@ -16,11 +17,13 @@ namespace New_College.Controllers
|
|||
private readonly IT_EnrollmentPlaneServices t_EnrollmentPlane;
|
||||
|
||||
private readonly ID_LongIdMapServices d_LongIdMapServices;
|
||||
|
||||
public HealthCheckController(IT_EnrollmentPlaneServices t_EnrollmentPlaneServices, ID_LongIdMapServices d_LongIdMapServices)
|
||||
|
||||
private readonly IV_CustomerInfoServices v_CustomerInfoServices;
|
||||
public HealthCheckController(IT_EnrollmentPlaneServices t_EnrollmentPlaneServices, ID_LongIdMapServices d_LongIdMapServices, IV_CustomerInfoServices _CustomerInfoServices)
|
||||
{
|
||||
t_EnrollmentPlane = t_EnrollmentPlaneServices;
|
||||
this.d_LongIdMapServices = d_LongIdMapServices;
|
||||
v_CustomerInfoServices = _CustomerInfoServices;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -52,10 +55,10 @@ namespace New_College.Controllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public Task<bool> Post()
|
||||
public async Task<bool> Post()
|
||||
{
|
||||
// return t_EnrollmentPlane.Import();
|
||||
// return t_EnrollmentPlane.Importuniverbaseinfo();
|
||||
// return t_EnrollmentPlane.Importuniverbaseinfo();
|
||||
|
||||
// return t_EnrollmentPlane.universitydetailupdate();
|
||||
|
||||
|
|
@ -64,10 +67,11 @@ namespace New_College.Controllers
|
|||
// return t_EnrollmentPlane.categoryupdate();
|
||||
|
||||
|
||||
// return d_LongIdMapServices.UpdateUniveristyInf();
|
||||
// return d_LongIdMapServices.Import();
|
||||
// return d_LongIdMapServices.UpdateUniveristyInf();
|
||||
// return d_LongIdMapServices.Import();
|
||||
|
||||
return d_LongIdMapServices.UpdatePlanProInf();
|
||||
await v_CustomerInfoServices.CustomeBillExport();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ namespace New_College.Controllers
|
|||
return new MessageModel<CasDoorToken>()
|
||||
{
|
||||
msg = "code已失效",
|
||||
success = false
|
||||
success = false,
|
||||
status = 401,
|
||||
};
|
||||
}
|
||||
response.servicetoken = getaccesstoken.access_token;
|
||||
|
|
@ -118,6 +119,7 @@ namespace New_College.Controllers
|
|||
}
|
||||
}
|
||||
baseuser.UUID = userinfo.sub;
|
||||
user = baseuser;
|
||||
await _CustomerInfoServices.Update(baseuser);
|
||||
}
|
||||
}
|
||||
|
|
@ -144,7 +146,7 @@ namespace New_College.Controllers
|
|||
single.NickName = user.UserCode;
|
||||
}
|
||||
await _CustomerInfoServices.Update(single);
|
||||
}
|
||||
}
|
||||
}
|
||||
TokenModelJwt tokenModel = new TokenModelJwt { Uid = user.Id, Role = "users" };
|
||||
jwtStr = JwtHelper.IssueJwt(tokenModel);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@
|
|||
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -102,6 +104,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Folder Include="Log\" />
|
||||
<Folder Include="wwwroot\Content\Upload\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||
|
|
|
|||
|
|
@ -5755,6 +5755,36 @@
|
|||
未完成人数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerExportModel.Gender">
|
||||
<summary>
|
||||
性别 1男 2女
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerExportModel.AreaName">
|
||||
<summary>
|
||||
省市区名称
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerExportModel.Datainit">
|
||||
<summary>
|
||||
学生数据是否初始化(省份,选科等)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerExportModel.Expectedscore">
|
||||
<summary>
|
||||
考生预计分数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerExportModel.IsVIP">
|
||||
<summary>
|
||||
是否为VIP
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerExportModel.Year">
|
||||
<summary>
|
||||
学届
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.CustomerInfoResult.Status">
|
||||
<summary>
|
||||
返回状态1成功 2验证码错误 3失败
|
||||
|
|
|
|||
|
|
@ -69,6 +69,16 @@ namespace New_College
|
|||
|
||||
SHanDongTel.Tel = Appsettings.app(new string[] { "SHanDongTel", "Tel" });
|
||||
|
||||
SHanDongTel.Mail = Appsettings.app(new string[] { "SHanDongTel", "Mail" });
|
||||
//邮箱
|
||||
MailKitConfig.DisplayName = Appsettings.app(new string[] { "MailKit", "DisplayName" }).ToString();
|
||||
MailKitConfig.Password = Appsettings.app(new string[] { "MailKit", "Password" }).ToString();
|
||||
MailKitConfig.MailAddress = Appsettings.app(new string[] { "MailKit", "MailAddress" }).ToString();
|
||||
MailKitConfig.IsSsl = Appsettings.app(new string[] { "MailKit", "IsSsl" }).ObjToBool();
|
||||
MailKitConfig.MailServer = Appsettings.app(new string[] { "MailKit", "MailServer" }).ToString();
|
||||
MailKitConfig.SmtpPort = Appsettings.app(new string[] { "MailKit", "SmtpPort" }).ObjToInt();
|
||||
|
||||
|
||||
//阿里云oss配置
|
||||
AliYunOssConfig.wendpoint = Appsettings.app(new string[] { "AliYunOss", "wendpoint" }).ObjToString();
|
||||
AliYunOssConfig.accessKeyId = Appsettings.app(new string[] { "AliYunOss", "accessKeyId" }).ObjToString();
|
||||
|
|
|
|||
|
|
@ -211,17 +211,17 @@
|
|||
"wendpoint": "https://static-data.ycymedu.com",
|
||||
"accessKeyId": "LTAI5tKs3TXSbt7E4WMDcxwR",
|
||||
"accessKeySecret": "EvC8MjRaQC1kHubgU4MtecZnofOb0v",
|
||||
"bucket": "static-data-ycymedu",
|
||||
"bucket": "static-ycymedu-minpro",
|
||||
"endpoint": "https://oss-cn-shanghai.aliyuncs.com"
|
||||
},
|
||||
"Casdoor": {
|
||||
"Endpoint": "http://192.168.103.119:8000",
|
||||
"Endpoint": "http://192.168.104.107:8000",
|
||||
"OrganizationName": "六纬生涯",
|
||||
"ApplicationName": "六纬生涯",
|
||||
"ApplicationType": "webapi",
|
||||
"ClientId": "776d639918192c449537",
|
||||
"ClientSecret": "d556f0692052a2df56614282dd86895b04783262",
|
||||
"CallbackPath": "http://test.sso.ycymedu.com/login/oauth/authorize?client_id=4c6d761417dbbdd665be&response_type=code&redirect_uri=http://192.168.100.129:8081/Home/FirstPage&scope=read&state=casdoor",
|
||||
"CallbackPath": "http://test.sso.ycymedu.com/login/oauth/authorize?client_id=776d639918192c449537&response_type=code&redirect_uri=http://192.168.100.106:8080/Home/FirstPage&scope=read&state=casdoor",
|
||||
"RequireHttpsMetadata": false
|
||||
},
|
||||
"WeChatPay": {
|
||||
|
|
@ -250,7 +250,17 @@
|
|||
"Url": "http://api.carrerwebapi.com/api/oauth/SyncUpdateStudentInfo"
|
||||
},
|
||||
"SHanDongTel": {
|
||||
"Tel": "15662627992|18724728603|17362186261|15264182912"
|
||||
"Tel": "15662627992|18724728603|17362186261|15264182912",
|
||||
"Mail": "156663459@qq.com"
|
||||
|
||||
},
|
||||
"MailKit": {
|
||||
"DisplayName": "六纬技术团队",
|
||||
"Password": "Vs..127134",
|
||||
"MailAddress": "yly@ycymedu.com",
|
||||
"IsSsl": "true",
|
||||
"MailServer": "smtp.ym.163.com",
|
||||
"SmtpPort": "465"
|
||||
|
||||
},
|
||||
"XiaoETONG": {
|
||||
|
|
|
|||
|
|
@ -215,13 +215,13 @@
|
|||
"endpoint": "https://oss-cn-shanghai.aliyuncs.com"
|
||||
},
|
||||
"Casdoor": {
|
||||
"Endpoint": "http://192.168.103.119:8000",
|
||||
"Endpoint": "http://192.168.104.107:8000",
|
||||
"OrganizationName": "六纬生涯",
|
||||
"ApplicationName": "六纬生涯",
|
||||
"ApplicationType": "webapi",
|
||||
"ClientId": "4c6d761417dbbdd665be",
|
||||
"ClientSecret": "cc385a5d0efd5f7bf693d8c4574126158f7b0a8f",
|
||||
"CallbackPath": "http://192.168.103.119:8000/login/oauth/authorize?client_id=ae6bdccc3a7821232b31&response_type=code&redirect_uri=http://192.168.103.100:8083/callback&scope=read&state=casdoor",
|
||||
"CallbackPath": "http://192.168.104.107:8000/login/oauth/authorize?client_id=ae6bdccc3a7821232b31&response_type=code&redirect_uri=http://192.168.103.100:8083/callback&scope=read&state=casdoor",
|
||||
"RequireHttpsMetadata": false
|
||||
},
|
||||
"WeChatPay": {
|
||||
|
|
@ -246,7 +246,17 @@
|
|||
"SerialNumber": "1B304596B953D156B37863FF52FCAE40B458C9F2" //(新)证书序列号
|
||||
},
|
||||
"SHanDongTel": {
|
||||
"Tel": "15662627992|18724728603|17362186261|15264182912"
|
||||
"Tel": "15662627992|18724728603|17362186261|15264182912",
|
||||
"Mail": "2461966073@qq.com"
|
||||
},
|
||||
"MailKit": {
|
||||
"DisplayName": "六纬技术团队",
|
||||
"Password": "Vs..127134",
|
||||
"MailAddress": "yly@ycymedu.com",
|
||||
"IsSsl": "true",
|
||||
"MailServer": "smtp.ym.163.com",
|
||||
"SmtpPort": "465"
|
||||
|
||||
},
|
||||
"XiaoETONG": {
|
||||
"app_id": "appn9m3yups9098",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
using NPOI.XSSF.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Common
|
||||
{
|
||||
public static class ListExportExcelUtil
|
||||
{
|
||||
|
||||
public static void ExportToExcel(List<CustomeExportModel> data, string filePath)
|
||||
{
|
||||
// 创建一个新的XSSFWorkbook(用于.xlsx格式)
|
||||
using var workbook = new XSSFWorkbook();
|
||||
|
||||
// 在工作簿中创建一个工作表
|
||||
var sheet = workbook.CreateSheet("Sheet1");
|
||||
|
||||
// 定义标题行(根据YourModel属性)
|
||||
var headerRow = sheet.CreateRow(0);
|
||||
headerRow.CreateCell(0).SetCellValue("性别");
|
||||
headerRow.CreateCell(1).SetCellValue("手机号");
|
||||
headerRow.CreateCell(2).SetCellValue("高考年份");
|
||||
headerRow.CreateCell(3).SetCellValue("学校");
|
||||
headerRow.CreateCell(4).SetCellValue("省份");
|
||||
headerRow.CreateCell(5).SetCellValue("否初始化");
|
||||
headerRow.CreateCell(6).SetCellValue("学生分数");
|
||||
headerRow.CreateCell(7).SetCellValue("选科组合");
|
||||
headerRow.CreateCell(8).SetCellValue("是否vip");
|
||||
headerRow.CreateCell(9).SetCellValue("注册时间");
|
||||
|
||||
// 遍历数据列表并写入Excel
|
||||
for (var i = 0; i < data.Count; i++)
|
||||
{
|
||||
var item = data[i];
|
||||
var row = sheet.CreateRow(i + 1); // 从第1行开始写数据
|
||||
|
||||
// 将模型属性值写入对应的单元格
|
||||
row.CreateCell(0).SetCellValue(item.Gender);
|
||||
row.CreateCell(1).SetCellValue(item.Phone);
|
||||
row.CreateCell(2).SetCellValue(item.Year);
|
||||
row.CreateCell(3).SetCellValue(item.SchoolName);
|
||||
row.CreateCell(4).SetCellValue(item.AreaName);
|
||||
row.CreateCell(5).SetCellValue(item.Datainit);
|
||||
row.CreateCell(6).SetCellValue(item.Expectedscore.Value);
|
||||
row.CreateCell(7).SetCellValue(item.subjectgroupName);
|
||||
row.CreateCell(8).SetCellValue(item.IsVIP);
|
||||
row.CreateCell(9).SetCellValue(item.CreateTime);
|
||||
// ... 对其他属性进行相同操作
|
||||
}
|
||||
|
||||
// 保存到指定文件路径
|
||||
using var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write);
|
||||
workbook.Write(fileStream);
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomeExportModel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 性别 1男 2女
|
||||
/// </summary>
|
||||
public string Gender { get; set; }
|
||||
/// <summary>
|
||||
/// 省市区名称
|
||||
/// </summary>
|
||||
public string AreaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///学生数据是否初始化(省份,选科等)
|
||||
/// </summary>
|
||||
public string Datainit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 考生预计分数
|
||||
/// </summary>
|
||||
public double? Expectedscore { get; set; } = 0;
|
||||
|
||||
public string subjectgroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为VIP
|
||||
/// </summary>
|
||||
public string IsVIP { get; set; }
|
||||
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 学届
|
||||
/// </summary>
|
||||
public int Year { get; set; }
|
||||
|
||||
public string SchoolName { get; set; }
|
||||
|
||||
|
||||
public string CreateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,30 @@
|
|||
{
|
||||
public static string Tel { get; set; }
|
||||
|
||||
public static string Mail { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱配置
|
||||
/// </summary>
|
||||
public static class MailKitConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 发送邮件人别名
|
||||
/// </summary>
|
||||
public static string DisplayName { get; set; }
|
||||
/// <summary>
|
||||
/// 发送邮件id
|
||||
/// </summary>
|
||||
public static string MailAddress { get; set; }
|
||||
public static bool IsSsl { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static string MailServer { get; set; }
|
||||
public static int SmtpPort { get; set; }
|
||||
public static string Password { get; set; }
|
||||
}
|
||||
|
||||
public static class WeixinConfig
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Aliyun.OSS.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
||||
|
|
@ -9,7 +10,44 @@ namespace New_College.Common
|
|||
{
|
||||
public class AliYunOssHelper
|
||||
{
|
||||
// private readonly static AliYunOssConfig ossConfig = GlobalData.AliYunOss;
|
||||
// private readonly static AliYunOssConfig ossConfig = GlobalData.AliYunOss;
|
||||
|
||||
/// <summary>
|
||||
/// OSS下载
|
||||
/// </summary>
|
||||
/// <param name="downloadFilepath"></param>
|
||||
/// <param name="filepath"></param>
|
||||
/// <returns></returns>
|
||||
public static string DownloadFile(string key, string filepath)
|
||||
{
|
||||
// 创建OssClient实例。
|
||||
var client = new OssClient(AliYunOssConfig.endpoint, AliYunOssConfig.accessKeyId, AliYunOssConfig.accessKeySecret);
|
||||
try
|
||||
{
|
||||
// 下载文件到流。OssObject 包含了文件的各种信息,如文件所在的存储空间、文件名、元信息以及一个输入流。
|
||||
var obj = client.GetObject(AliYunOssConfig.bucket, filepath);
|
||||
using (var requestStream = obj.Content)
|
||||
{
|
||||
byte[] buf = new byte[1024];
|
||||
var fs = File.Open(key, FileMode.OpenOrCreate);
|
||||
var len = 0;
|
||||
// 通过输入流将文件的内容读取到文件或者内存中。
|
||||
while ((len = requestStream.Read(buf, 0, 1024)) != 0)
|
||||
{
|
||||
fs.Write(buf, 0, len);
|
||||
}
|
||||
fs.Close();
|
||||
}
|
||||
Console.WriteLine("Get object succeeded");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Get object failed. {0}", ex.Message);
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string UploadFile(string key, string filepath)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,112 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Common.Helper
|
||||
{
|
||||
public static class FileZipHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 批量压缩上传
|
||||
/// </summary>
|
||||
/// <param name="webHost"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <param name="mangeName"></param>
|
||||
/// <param name="isuploadOss"></param>
|
||||
/// <returns></returns>
|
||||
public static string FileMultipZipUpload(IWebHostEnvironment webHost, List<FileModel> files, string mangeName, bool isuploadOss = true)
|
||||
{
|
||||
string zipstr = string.Empty;
|
||||
try
|
||||
{
|
||||
|
||||
var tmplist = new List<string>();
|
||||
string rootdir = webHost.WebRootPath + "/" + mangeName;
|
||||
string zipname = mangeName + ".zip";
|
||||
string ossfileUrl = webHost.WebRootPath + "/" + zipname;
|
||||
if (!Directory.Exists(rootdir))
|
||||
{
|
||||
Directory.CreateDirectory(rootdir);
|
||||
}
|
||||
int tmpid = 0;
|
||||
files.ForEach(a =>
|
||||
{
|
||||
string userdir = rootdir + "/" + a.UserName;
|
||||
if (!Directory.Exists(userdir))
|
||||
{
|
||||
Directory.CreateDirectory(userdir);
|
||||
}
|
||||
tmpid++;
|
||||
int k = 0;
|
||||
a.fileItems.ForEach(s =>
|
||||
{
|
||||
if (s.ImgUrl.Contains("http"))
|
||||
{
|
||||
k++;
|
||||
string filename = string.Format("{0}/{1}.{2}-{3}-{4}{5}", userdir, tmpid, s.typeName, a.UserName, k, Path.GetExtension(s.ImgUrl));
|
||||
// Wb_Client(s.ImgUrl, filename);
|
||||
tmplist.Add(filename);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (File.Exists(ossfileUrl))
|
||||
{
|
||||
File.Delete(ossfileUrl);
|
||||
}
|
||||
ZipFile.CreateFromDirectory(rootdir, ossfileUrl);
|
||||
|
||||
if (isuploadOss)
|
||||
{
|
||||
zipstr = AliYunOssHelper.UploadFile(zipname, ossfileUrl);
|
||||
if (!string.IsNullOrEmpty(zipstr))
|
||||
{
|
||||
tmplist.Add(ossfileUrl);
|
||||
tmplist.ForEach(d =>
|
||||
{
|
||||
File.Delete(d);
|
||||
});
|
||||
Directory.Delete(rootdir, true);
|
||||
}
|
||||
return zipstr;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmplist.ForEach(d =>
|
||||
{
|
||||
File.Delete(d);
|
||||
});
|
||||
Directory.Delete(rootdir, true);
|
||||
return zipname;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DingHookHelper.DingTalkHookMessage("zip压缩错误", ex.Message);
|
||||
return "zip压缩错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class FileModel
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
|
||||
public List<FileItemModel> fileItems { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class FileItemModel
|
||||
{
|
||||
public string typeName { get; set; }
|
||||
public string ImgUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
using MimeKit.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Common.Helper
|
||||
{
|
||||
|
||||
|
||||
public static class MailKitManagement
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// send email
|
||||
/// </summary>
|
||||
/// <param name="toMailAddressList"></param>
|
||||
/// <param name="ccAddresList"></param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="body"></param>
|
||||
/// <param name="attachmentList"></param>
|
||||
/// <param name="isHtml"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task SendMessageAsync(List<string> toMailAddressList, List<string> ccAddresList, string subject, string body, List<string> attachmentList = null, bool isHtml = false)
|
||||
{
|
||||
var mailMessage = new MimeMessage();
|
||||
mailMessage.From.Add(new MailboxAddress(MailKitConfig.DisplayName, MailKitConfig.MailAddress));
|
||||
foreach (var mailAddressItem in toMailAddressList)
|
||||
{
|
||||
mailMessage.To.Add(MailboxAddress.Parse(mailAddressItem));
|
||||
}
|
||||
if (ccAddresList != null)
|
||||
{
|
||||
ccAddresList.ForEach(p =>
|
||||
{
|
||||
mailMessage.Cc.Add(MailboxAddress.Parse(p));
|
||||
});
|
||||
}
|
||||
|
||||
mailMessage.Subject = subject;
|
||||
TextPart messageBody = null;
|
||||
if (isHtml)
|
||||
{
|
||||
messageBody = new TextPart(TextFormat.Html)
|
||||
{
|
||||
Text = body,
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBody = new TextPart(TextFormat.Plain)
|
||||
{
|
||||
Text = body,
|
||||
};
|
||||
}
|
||||
var mulitiPart = new Multipart("mixed")
|
||||
{
|
||||
};
|
||||
mulitiPart.Add(messageBody);
|
||||
if (attachmentList != null && attachmentList.Count > 0)
|
||||
{
|
||||
foreach (var attatchItem in attachmentList)
|
||||
{
|
||||
using (var stream = File.OpenRead(attatchItem))
|
||||
{
|
||||
var attachment = new MimePart()
|
||||
{
|
||||
Content = new MimeContent(stream, ContentEncoding.Default),
|
||||
ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
|
||||
ContentTransferEncoding = ContentEncoding.Base64,
|
||||
FileName = Path.GetFileName(attatchItem)
|
||||
};
|
||||
mulitiPart.Add(attachment);
|
||||
}
|
||||
}
|
||||
}
|
||||
mailMessage.Body = mulitiPart;
|
||||
using (var client = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
if (MailKitConfig.IsSsl)
|
||||
{
|
||||
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
}
|
||||
|
||||
client.Connect(MailKitConfig.MailServer, MailKitConfig.SmtpPort, MailKitConfig.IsSsl);
|
||||
|
||||
// Disable the XOAUTH2 authentication mechanism.
|
||||
//client.AuthenticationMechanisms.Remove("XOAUTH2");
|
||||
|
||||
// Note: only needed if the SMTP server requires authentication
|
||||
client.Authenticate(MailKitConfig.MailAddress, MailKitConfig.Password);
|
||||
await client.SendAsync(mailMessage);
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||
<PackageReference Include="NETCore.MailKit" Version="2.1.0" />
|
||||
<PackageReference Include="NodaTime" Version="3.0.1" />
|
||||
<PackageReference Include="NPOI" Version="2.6.0" />
|
||||
<PackageReference Include="OSS.Clients.Pay.Wechat" Version="2.4.0" />
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ namespace New_College.Extensions
|
|||
//services.AddHostedService<Job2TimedService>();
|
||||
services.AddHostedService<JobTimedSpiderService>();
|
||||
services.AddHostedService<UserBaseSettingJobTimedService>();
|
||||
services.AddHostedService<ExcelExportJobTimedService>();
|
||||
services.AddSingleton<IJobFactory, JobFactory>();
|
||||
services.AddTransient<Job_Blogs_Quartz>();//Job使用瞬时依赖注入
|
||||
services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>();
|
||||
|
|
|
|||
|
|
@ -71,5 +71,9 @@ namespace New_College.IServices
|
|||
/// <returns></returns>
|
||||
Task<int> CustomerSave(DecryptUserInfoRequest register);
|
||||
|
||||
|
||||
|
||||
Task CustomeBillExport();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,49 @@ namespace New_College.Model.ViewModels
|
|||
public string nickName { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class CustomerExportModel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 性别 1男 2女
|
||||
/// </summary>
|
||||
public string Gender { get; set; }
|
||||
/// <summary>
|
||||
/// 省市区名称
|
||||
/// </summary>
|
||||
public string AreaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///学生数据是否初始化(省份,选科等)
|
||||
/// </summary>
|
||||
public string Datainit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 考生预计分数
|
||||
/// </summary>
|
||||
public double? Expectedscore { get; set; } = 0;
|
||||
|
||||
public string subjectgroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为VIP
|
||||
/// </summary>
|
||||
public string IsVIP { get; set; }
|
||||
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 学届
|
||||
/// </summary>
|
||||
public int Year { get; set; }
|
||||
|
||||
public string SchoolName { get; set; }
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class CustomerInfoResult
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ using New_College.Common.HttpRestSharp;
|
|||
using StackExchange.Profiling.Internal;
|
||||
using New_College.Repository;
|
||||
using System.Xml.Linq;
|
||||
using NPOI.HPSF;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace New_College.Services
|
||||
{
|
||||
|
|
@ -29,7 +33,8 @@ namespace New_College.Services
|
|||
private readonly ICasdoorUserRepository _casdoorUserRepository;
|
||||
private readonly ID_UserSettingBaseServices _userSetting;
|
||||
private readonly ID_XiaoEtongUserRepository _XiaoEtongUserRepository;
|
||||
public V_CustomerInfoServices(IBaseRepository<V_CustomerInfo> dal, IT_BatchlineRepository t_Batchline, ICasdoorUserRepository casdoorUserRepository, ID_UserSettingBaseServices userSetting, ID_XiaoEtongUserRepository d_XiaoEtongUserRepository)
|
||||
private readonly IWebHostEnvironment environment;
|
||||
public V_CustomerInfoServices(IBaseRepository<V_CustomerInfo> dal, IT_BatchlineRepository t_Batchline, ICasdoorUserRepository casdoorUserRepository, ID_UserSettingBaseServices userSetting, ID_XiaoEtongUserRepository d_XiaoEtongUserRepository, IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
this._dal = dal;
|
||||
base.BaseDal = dal;
|
||||
|
|
@ -37,6 +42,7 @@ namespace New_College.Services
|
|||
_casdoorUserRepository = casdoorUserRepository;
|
||||
_userSetting = userSetting;
|
||||
_XiaoEtongUserRepository = d_XiaoEtongUserRepository;
|
||||
environment = webHostEnvironment;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -355,7 +361,7 @@ namespace New_College.Services
|
|||
string typename = "综合";
|
||||
if (info.subjectgroupName != null)
|
||||
{
|
||||
typename = info.subjectgroupName.Length > 2 ? "综合" : info.subjectgroupName;
|
||||
typename = info.subjectgroupName.Length > 2 ? "综合" : info.subjectgroupName;
|
||||
|
||||
}
|
||||
var batchlist = await t_BatchlineRepository.Query(c => c.Year == years && c.AreaName == info.AreaName && c.Type_name == typename);
|
||||
|
|
@ -684,5 +690,54 @@ namespace New_College.Services
|
|||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 定期抓取数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task CustomeBillExport()
|
||||
{
|
||||
var customer = await _dal.Query(c => c.IsDelete == false && c.CreateTime >= DateTime.Now.AddDays(-7));
|
||||
|
||||
if (customer.Any())
|
||||
{
|
||||
var clist = new List<CustomeExportModel>();
|
||||
customer.ForEach(c =>
|
||||
{
|
||||
clist.Add(new CustomeExportModel()
|
||||
{
|
||||
AreaName = c.AreaName,
|
||||
Datainit = c.Datainit.Value ? "是" : "否",
|
||||
Expectedscore = c.Expectedscore,
|
||||
Gender = c.Gender == 1 ? "男" : c.Gender == 2 ? "女" : "未填写",
|
||||
IsVIP = c.IsVIP ? "是" : "否",
|
||||
Phone = c.Phone,
|
||||
SchoolName = c.SchoolName,
|
||||
subjectgroupName = c.subjectgroupName,
|
||||
Year = c.Year,
|
||||
CreateTime = c.CreateTime.Value.ToString()
|
||||
});
|
||||
});
|
||||
|
||||
var outputPath = string.Format("output_{0}.xlsx", DateTime.Now.ToString("yyyyMMddHHssfff")); // 或指定完整的文件路径
|
||||
var path = environment.WebRootPath;
|
||||
string urlPath = $"/Content/Upload/";
|
||||
var newpath = path + urlPath + outputPath;
|
||||
string DirectoryName = Path.GetDirectoryName(path + urlPath);
|
||||
if (!Directory.Exists(DirectoryName))
|
||||
Directory.CreateDirectory(DirectoryName);
|
||||
ListExportExcelUtil.ExportToExcel(clist, newpath);
|
||||
|
||||
string outputres = "Excel/"+outputPath;
|
||||
string outputurl = AliYunOssHelper.UploadFile(outputres, newpath);
|
||||
|
||||
await MailKitManagement.SendMessageAsync(new List<string>() { SHanDongTel.Mail }, new List<string>() { }, "六纬志愿技术团队", string.Format("文件下载地址:<a href='{0}'>上周用户数据</a></p>", outputurl), null, true);
|
||||
System.IO.File.Delete(newpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
using New_College.Common.Helper;
|
||||
using New_College.IServices;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Tasks
|
||||
{
|
||||
public class ExcelExportJobTimedService : IHostedService, IDisposable
|
||||
{
|
||||
private Timer _timer;
|
||||
private readonly IV_CustomerInfoServices _customerInfoServices;
|
||||
// private readonly Action _taskAction;
|
||||
|
||||
// 这里可以注入
|
||||
public ExcelExportJobTimedService(IV_CustomerInfoServices v_CustomerInfoServices)
|
||||
{
|
||||
_customerInfoServices = v_CustomerInfoServices;
|
||||
|
||||
// _taskAction = taskAction ?? throw new ArgumentNullException(nameof(taskAction));
|
||||
|
||||
// 初始化定时器
|
||||
_timer = new Timer(async state =>
|
||||
{
|
||||
// 执行任务
|
||||
await ExecuteTaskAsync();
|
||||
|
||||
// 计算下一次执行时间
|
||||
DateTime nextExecutionTime = CalculateNextMondayMorning(8);
|
||||
|
||||
// 重新设置定时器间隔,确保在下周一早上8点触发
|
||||
TimeSpan timeUntilNextExecution = nextExecutionTime - DateTime.Now;
|
||||
if (timeUntilNextExecution.TotalMilliseconds > 0)
|
||||
{
|
||||
_timer.Change(timeUntilNextExecution, TimeSpan.FromMilliseconds(-1));
|
||||
}
|
||||
}, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(-1));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task ExecuteTaskAsync()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await _customerInfoServices.CustomeBillExport();
|
||||
Console.WriteLine($"ExportJob 启动成功");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Error:{ex.Message}");
|
||||
}
|
||||
|
||||
ConsoleHelper.WriteSuccessLine($"Job ExportJob: {DateTime.Now}");
|
||||
});
|
||||
}
|
||||
|
||||
private static DateTime CalculateNextMondayMorning(int hour)
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime nextMonday = GetNextMonday(now);
|
||||
return new DateTime(nextMonday.Year, nextMonday.Month, nextMonday.Day, hour, 0, 0, DateTimeKind.Local);
|
||||
}
|
||||
|
||||
private static DateTime GetNextMonday(DateTime input)
|
||||
{
|
||||
DayOfWeek dayOfWeek = input.DayOfWeek;
|
||||
int daysUntilMonday = ((int)DayOfWeek.Monday - (int)dayOfWeek + 7) % 7;
|
||||
return input.AddDays(daysUntilMonday);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Console.WriteLine("ExcelExportJob is starting.");
|
||||
|
||||
// 启动定时器
|
||||
_timer.Change(TimeSpan.Zero, TimeSpan.FromMilliseconds(-1));
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
//private async void DoWork(object state)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// await _customerInfoServices.CustomeBillExport();
|
||||
// Console.WriteLine($"ExportJob 启动成功");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"Error:{ex.Message}");
|
||||
// }
|
||||
|
||||
// ConsoleHelper.WriteSuccessLine($"Job ExportJob: {DateTime.Now}");
|
||||
//}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Console.WriteLine("ExportJob is stopping.");
|
||||
|
||||
// 停止定时器
|
||||
_timer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_timer?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue