public override IChannel getChannelInstance(ServiceType Servicetype, string Endpoint, IContent Content) { if (ServiceType.Email == Servicetype) { return(EmailChannel.getEmailInstance(Endpoint, Content)); } throw new NotImplementedException(); }
/// <summary> /// 添加邮件通知 /// </summary> /// <param name="msOptions"></param> /// <param name="options">选项</param> public static void AddEmailNotifyChannel(this IMonitorOptions msOptions, Action <EmailChannelOptions> options) { var opt = new EmailChannelOptions(); options?.Invoke(opt); var channel = new EmailChannel(opt); msOptions.NotifyChannels.Add(channel); }
public override async ValueTask HandleAsync(FixtureEvent fixtureEvent) { Fixture fixture = await FindFixtureAsync(fixtureEvent); if (fixture.CanCheckout()) { fixture.Status = FixtureStatus.ExternalCheckoutApply; await EmailChannel.AddNotificationEmailAsync( "*****@*****.**", Repository.AdminRoles.Select(item => item.Email), $"no-reply: Fixture{fixtureEvent.FixtureNo} need to checkout", "<div>Check the link:</div><a href=\"http://10.99.159.149:83/\">link</a>"); } else { throw new InvalidOperationException( $"Fixture No: ${fixtureEvent.FixtureNo} is in checkout procedure"); } }
public override async ValueTask HandleAsync(FixtureEvent fixtureEvent) { Fixture fixture = await FindFixtureAsync(fixtureEvent); if (fixture.Status is FixtureStatus.ExternalCheckoutApply) { fixture.Status = FixtureStatus.ExternalCheckoutApprove; //Todo Send email notification here FixtureExternalCheckoutApplyEvent?applyEvent = Repository.FixtureEventsInDatabase.Where(item => item.FixtureNo == fixtureEvent.FixtureNo) .LastOrDefault(item => item.ContentTypeFullName == typeof(FixtureExternalCheckoutApplyEvent).FullName)? .GetEvent() as FixtureExternalCheckoutApplyEvent; if (applyEvent == null) { throw new InvalidOperationException( $"Can't find apply event for this approve event! Fixture No:{fixtureEvent.FixtureNo}"); } Role?role = (await Repository.Roles.FindAsync(applyEvent?.ApplicantUserId)); if (role == null) { throw new InvalidOperationException($"Applicant: {applyEvent.ApplicantUserId} doesn't exist!"); } await EmailChannel.AddNotificationEmailAsync( "*****@*****.**", new[] { role.Email }, $"no-reply: Fixture {fixtureEvent.FixtureNo} checkout approved", "<div>Check the link:</div><a href=\"http://10.99.159.149:83/\">link</a>"); } else { throw new InvalidOperationException($"Fixture No: ${fixtureEvent.FixtureNo} is not in Apply status."); } }