监控时间
parent
84a505bcc4
commit
3de8087fcc
|
@ -63,7 +63,7 @@ namespace IRaCIS.Core.API
|
|||
|
||||
//Autofac 注册拦截器 需要注意的是生成api上服务上的动态代理AOP失效 间接掉用不影响
|
||||
containerBuilder.RegisterType<TrialStatusAutofacAOP>();
|
||||
containerBuilder.RegisterType<UserAddAOP>();
|
||||
//containerBuilder.RegisterType<UserAddAOP>();
|
||||
//containerBuilder.RegisterType<QANoticeAOP>();
|
||||
//containerBuilder.RegisterType<LogService>().As<ILogService>().SingleInstance();
|
||||
|
||||
|
|
|
@ -59,22 +59,7 @@ namespace IRaCIS.Application.Services
|
|||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateBasicDic(AddOrEditBasicDic addOrEditBasic)
|
||||
{
|
||||
//if (addOrEditBasic.Id == null)
|
||||
//{
|
||||
// var entity = await _dicRepository.InsertDictionaryAsync(addOrEditBasic);
|
||||
|
||||
// await _dicRepository.UpdateFromQueryAsync(t => t.ParentId == Guid.Empty,
|
||||
// u => new Dictionary() { ParentId = null });
|
||||
|
||||
// return ResponseOutput.Ok(entity.Id.ToString());
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
||||
|
||||
|
||||
// return ResponseOutput.Ok(entity.Id.ToString());
|
||||
//}
|
||||
var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true);
|
||||
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
|
|
@ -187,7 +187,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
|
||||
|
||||
public async Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode)
|
||||
{
|
||||
|
||||
|
@ -236,52 +235,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
}
|
||||
}
|
||||
public async Task SendEmailForExternalUser(string emailAddress, string verificationCode)
|
||||
{
|
||||
var messageToSend = new MimeMessage();
|
||||
//发件地址
|
||||
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
|
||||
//收件地址
|
||||
messageToSend.To.Add(new MailboxAddress(String.Empty, emailAddress));
|
||||
//主题
|
||||
messageToSend.Subject = "GRR External User survey (Verification Code)";
|
||||
|
||||
messageToSend.Body = new TextPart("plain")
|
||||
{
|
||||
Text = $@"Hey ,you are login for site survey via email. The verification code is: {verificationCode}, If it is not your own operation, please ignore it!
|
||||
|
||||
-- GRR"
|
||||
};
|
||||
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
|
||||
{
|
||||
smtp.MessageSent += (sender, args) =>
|
||||
{
|
||||
// args.Response
|
||||
var code = verificationCode.ToString();
|
||||
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
|
||||
{
|
||||
CodeType = 0,
|
||||
HasSend = true,
|
||||
Code = code,
|
||||
UserId = Guid.Empty,//此时不知道用户
|
||||
EmailOrPhone = emailAddress,
|
||||
ExpirationTime = DateTime.Now.AddMinutes(3)
|
||||
}).Result;
|
||||
_ = _verificationCodeRepository.SaveChangesAsync().Result;
|
||||
|
||||
};
|
||||
|
||||
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
|
||||
await smtp.ConnectAsync("smtp.163.com", 25, SecureSocketOptions.StartTls);
|
||||
|
||||
await smtp.AuthenticateAsync("iracis_grr@163.com", "XLWVQKZAEKLDWOAH");
|
||||
|
||||
await smtp.SendAsync(messageToSend);
|
||||
|
||||
await smtp.DisconnectAsync(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -56,6 +56,33 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
public string UploadStartTimeStr => UploadStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
public string UploadFinishedTimeStr => UploadFinishedTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
|
||||
public string TimeInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
var tSpan = UploadFinishedTime - UploadStartTime;
|
||||
|
||||
if (tSpan.Seconds == 0 && tSpan.Minutes==0 && tSpan.Hours == 0)
|
||||
{
|
||||
return $"{tSpan.Milliseconds}毫秒";
|
||||
}
|
||||
else if ( tSpan.Minutes == 0 && tSpan.Hours == 0)
|
||||
{
|
||||
return $"{tSpan.Seconds}秒";
|
||||
}
|
||||
else if ( tSpan.Hours == 0)
|
||||
{
|
||||
return $"{tSpan.Minutes} 分钟 {tSpan.Seconds} 秒";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $" {tSpan.Hours} 小时 {tSpan.Minutes} 分钟 {tSpan.Seconds} 秒";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime UploadStartTime { get; set; }
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
using IRaCIS.Core.Infrastructure.ExpressionExtend;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using System.Text.RegularExpressions;
|
||||
using Autofac.Extras.DynamicProxy;
|
||||
using IRaCIS.Core.API.Utility.AOP;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Panda.DynamicWebApi.Attributes;
|
||||
|
@ -15,7 +10,6 @@ using Microsoft.AspNetCore.Authorization;
|
|||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "Management")]
|
||||
[Intercept(typeof(UserAddAOP))]
|
||||
public class UserService : BaseService, IUserService
|
||||
{
|
||||
private readonly IRepository<User> _userRepository;
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace IRaCIS.Core.Application
|
|||
public async Task<IResponseOutput> UpdateTrialState(Guid trialId, string trialStatusStr, Guid signId, string? reason, [FromServices] IEasyCachingProvider _provider)
|
||||
{
|
||||
|
||||
var trial = await _trialRepository.Where(t => t.Id == trialId, true).IgnoreQueryFilters().FirstOrDefaultAsync().IfNullThrowException();
|
||||
var trial = (await _trialRepository.Where(t => t.Id == trialId, true).IgnoreQueryFilters().FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
if (trialStatusStr == StaticData.TrialOngoing)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue