<cite>aaron: </cite> Tip: Wrap your code in the following for formatting and readability:
[code]
[/code:39lrdbwm] A shortcut is to highlight your code and click on the </> button in the formatting toolbar.
I did that wrap my code in <code> tage can tell me what the next step to apply the filter on the all query
Sorry I set the below implementation 1)
public interface IHasCustomer
{
string InsCustID { get; set; }
}
protected override bool ShouldFilterEntity<TEntity>(IMutableEntityType entityType)
{
return base.ShouldFilterEntity<TEntity>(entityType);
}
protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
{
Expression<Func<TEntity, bool>> expression = null;
if (typeof(IHasCustomer).IsAssignableFrom(typeof(TEntity)))
{
Expression<Func<TEntity, bool>> mustHaveTenantFilter = e => ((IHasCustomer)e).InsCustID == GetCurrentCustomerIdOrNull() || (((IHasCustomer)e).InsCustID == GetCurrentCustomerIdOrNull()) == true;
expression = expression == null ? mustHaveTenantFilter : CombineExpressions(expression, mustHaveTenantFilter);
}
return base.CreateFilterExpression<TEntity>();
}
my question what the next to run and apply the filter
I have aspzero, can you please provide us with example to set custom filler ?
OK, Thanks for your support.
How I can attach file to the email? does Frame Work support the attachment file when send the email ??
Dear
I commit the ReplaceService for IEmailSenderConfiguration but the password sent intercepted, so
I back the code as below but in same time I have error
MailKit.Security.AuthenticationException: 'AuthenticationInvalidCredentials: 5.7.3 Authentication unsuccessful'
public class DefaultMailKitSmtpBuilder : IMailKitSmtpBuilder, ITransientDependency { private readonly ISmtpEmailSenderConfiguration _smtpEmailSenderConfiguration; //private readonly IAbpMailKitConfiguration _abpMailKitConfiguration;
public DefaultMailKitSmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration)
{
_smtpEmailSenderConfiguration = smtpEmailSenderConfiguration;
}
public virtual SmtpClient Build()
{
var client = new SmtpClient();
try
{
ConfigureClient(client);
return client;
}
catch
{
client.Dispose();
throw;
}
}
protected virtual void ConfigureClient(SmtpClient client)
{
client.Connect(
_smtpEmailSenderConfiguration.Host,
_smtpEmailSenderConfiguration.Port,SecureSocketOptions.None
);
if (_smtpEmailSenderConfiguration.UseDefaultCredentials)
{
return;
}
client.Authenticate(
_smtpEmailSenderConfiguration.UserName,
_smtpEmailSenderConfiguration.Password
);
}
protected virtual SecureSocketOptions GetSecureSocketOption()
{
return _smtpEmailSenderConfiguration.EnableSsl
? SecureSocketOptions.SslOnConnect
: SecureSocketOptions.StartTlsWhenAvailable;
}
}
[DependsOn(
typeof(AbpZeroCoreModule),
typeof(AbpZeroLdapModule),
typeof(AbpAutoMapperModule),
typeof(AbpAspNetZeroCoreModule),
typeof(AbpMailKitModule))]
public class BarznWebCoreModule : AbpModule
{
public override void PreInitialize()
{
//workaround for issue: <a class="postlink" href="https://github.com/aspnet/EntityFrameworkCore/issues/9825">https://github.com/aspnet/EntityFramewo ... ssues/9825</a>
//related github issue: <a class="postlink" href="https://github.com/aspnet/EntityFrameworkCore/issues/10407">https://github.com/aspnet/EntityFramewo ... sues/10407</a>
AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue9825", true);
Configuration.Auditing.IsEnabledForAnonymousUsers = true;
//Declare entity types
Configuration.Modules.Zero().EntityTypes.Tenant = typeof(Tenant);
Configuration.Modules.Zero().EntityTypes.Role = typeof(Role);
Configuration.Modules.Zero().EntityTypes.User = typeof(User);
BarznWebLocalizationConfigurer.Configure(Configuration.Localization);
//Adding feature providers
Configuration.Features.Providers.Add<AppFeatureProvider>();
//Adding setting providers
Configuration.Settings.Providers.Add<AppSettingProvider>();
//Adding notification providers
Configuration.Notifications.Providers.Add<AppNotificationProvider>();
//Enable this line to create a multi-tenant application.
Configuration.MultiTenancy.IsEnabled = BarznWebConsts.MultiTenancyEnabled;
//Enable LDAP authentication (It can be enabled only if MultiTenancy is disabled!)
//Configuration.Modules.ZeroLdap().Enable(typeof(AppLdapAuthenticationSource));
//Configure roles
AppRoleConfig.Configure(Configuration.Modules.Zero().RoleManagement);
//if (DebugHelper.IsDebug)
//{
// //Disabling email sending in debug mode
// Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);
//}
//Configuration.ReplaceService(typeof(IEmailSenderConfiguration), () =>
//{
// Configuration.IocManager.IocContainer.Register(
// Component.For<IEmailSenderConfiguration, ISmtpEmailSenderConfiguration>()
// .ImplementedBy<BarznWebSmtpEmailSenderConfiguration>()
// .LifestyleTransient()
// );
//});
Configuration.ReplaceService(typeof(IEmailSenderConfiguration), () =>
{
Configuration.IocManager.IocContainer.Register(
Component.For<IEmailSenderConfiguration, ISmtpEmailSenderConfiguration>()
.ImplementedBy<BarznWebSmtpEmailSenderConfiguration>()
.LifestyleTransient()
);
});
Configuration.ReplaceService<IMailKitSmtpBuilder, DefaultMailKitSmtpBuilder>(DependencyLifeStyle.Transient);
Configuration.Caching.Configure(FriendCacheItem.CacheName, cache =>
{
cache.DefaultSlidingExpireTime = TimeSpan.FromMinutes(30);
});
Configuration.Caching.Configure(PaymentCacheItem.CacheName, cache =>
{
cache.DefaultSlidingExpireTime = TimeSpan.FromMinutes(BarznWebConsts.PaymentCacheDurationInMinutes);
});
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(typeof(BarznWebCoreModule).GetAssembly());
}
public override void PostInitialize()
{
IocManager.RegisterIfNot<IChatCommunicator, NullChatCommunicator>();
IocManager.Resolve<ChatUserStateWatcher>().Initialize();
IocManager.Resolve<AppTimes>().StartupTime = Clock.Now;
}
}
}
public class BarznWebSmtpEmailSenderConfiguration : SmtpEmailSenderConfiguration { public BarznWebSmtpEmailSenderConfiguration(ISettingManager settingManager) : base(settingManager) {
}
public override string Password => SimpleStringCipher.Instance.Decrypt(GetNotEmptySettingValue(EmailSettingNames.Smtp.Password));
}
Is this right ?? can you please check below Note I cannot define _abpMailKitConfiguration but the error appear System.Net.Sockets.SocketException: 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.16.2.119:25'
public class DefaultMailKitSmtpBuilder : IMailKitSmtpBuilder, ITransientDependency
{
private readonly ISmtpEmailSenderConfiguration _smtpEmailSenderConfiguration;
//private readonly IAbpMailKitConfiguration _abpMailKitConfiguration;
public DefaultMailKitSmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration)
{
_smtpEmailSenderConfiguration = smtpEmailSenderConfiguration;
}
public virtual SmtpClient Build()
{
var client = new SmtpClient();
try
{
ConfigureClient(client);
return client;
}
catch
{
client.Dispose();
throw;
}
}
protected virtual void ConfigureClient(SmtpClient client)
{
client.Connect(
_smtpEmailSenderConfiguration.Host,
_smtpEmailSenderConfiguration.Port,
GetSecureSocketOption()
);
if (_smtpEmailSenderConfiguration.UseDefaultCredentials)
{
return;
}
client.Authenticate(
_smtpEmailSenderConfiguration.UserName,
_smtpEmailSenderConfiguration.Password
);
}
protected virtual SecureSocketOptions GetSecureSocketOption()
{
return _smtpEmailSenderConfiguration.EnableSsl
? SecureSocketOptions.SslOnConnect
: SecureSocketOptions.StartTlsWhenAvailable;
}
}
//if (DebugHelper.IsDebug)
//{
// //Disabling email sending in debug mode
// Configuration.ReplaceService<IEmailSender, NullEmailSender>(DependencyLifeStyle.Transient);
//}
Configuration.ReplaceService(typeof(IEmailSenderConfiguration), () =>
{
Configuration.IocManager.IocContainer.Register(
Component.For<IEmailSenderConfiguration, ISmtpEmailSenderConfiguration>()
.ImplementedBy<BarznWebSmtpEmailSenderConfiguration>()
.LifestyleTransient()
);
});
Configuration.ReplaceService<IMailKitSmtpBuilder, DefaultMailKitSmtpBuilder>(DependencyLifeStyle.Transient);
<cite>maliming: </cite> You can refer to this reply to solve. [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3547#issuecomment-400181114])
Error MailKit.Security.AuthenticationException: 'AuthenticationInvalidCredentials: 5.7.3
Authentication unsuccessful' /// Define new class public class MyMailKitSmtpBuilder : DefaultMailKitSmtpBuilder { public MyMailKitSmtpBuilder(ISmtpEmailSenderConfiguration smtpEmailSenderConfiguration) : base(smtpEmailSenderConfiguration) { }
protected override void ConfigureClient(SmtpClient client)
{
client.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
base.ConfigureClient(client);
}
}
I implement in the PreInitialize below code /////////PreInitialize// Configuration.ReplaceService(typeof(IEmailSenderConfiguration), () => { Configuration.IocManager.IocContainer.Register( Component.For<IEmailSenderConfiguration, ISmtpEmailSenderConfiguration>() .ImplementedBy<BarznWebSmtpEmailSenderConfiguration>() .LifestyleTransient() ); }); Configuration.ReplaceService<IMailKitSmtpBuilder, MyMailKitSmtpBuilder>(DependencyLifeStyle.Transient); //////////////////////////////////////////////////////////////
<cite>maliming: </cite> Please check if the currently accessed user is granted permission.
Can you please check that I sent screenshot to you
<cite>alper: </cite> wouv! same time @maliming :)
in same time I call it and working now thanks
Dear All,
I download new version from ASPZero V5.5.2
and Clear All Nuget Cace(s) and restore All Nuget Packges on sln
but still the below error apears 9>C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(327,5): error : Assets file 'C:\Users\Barzan\source\repos\BarznWeb (6)\BarznWeb\src\BarznWeb.BarznWeb.Web.Host\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.