eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
221 stars 115 forks source link

EMail SmtpClient unable to select UserName when using UseDefaultCredentials False #1011

Closed yunits closed 8 months ago

yunits commented 1 year ago

Hello, I am testing your EMail Module and found an issue or maybe I miss something.

While configuring SmtpClients there is the option "UseDefaultCredentials". If I set it to False, I should be able to see for property UserName "Property type: Xpand.XAF.Modules.Email.IModelEmailAddress, Member of interface: Xpand.XAF.Modules.Email.IModelEmailSmtpClient" entries, same as in "From" property.

DXApplication4.zip

image

apobekiaris commented 1 year ago

I am not sure what u mean, anyways u could simply look where this property is used e.g. it sets the related smtpclient prop which does not do what u said

image

in addition this how it should work

image

let me know if it resolves your issues

yunits commented 1 year ago

I mean there are no entries in my property "UserName" if I choose UseDefaultCredentials = False. If I search at github in your repo for "Credentials" it will show me the file "Reactive.XAF/src/Modules/Email/ModelLogic.cs"

Here we have From, with "DataSourceProperty(nameof(FromEmails)" and UserName that has no DataSourceProperty. Could that be the reason?

        [Required][DataSourceProperty(nameof(FromEmails))]
        IModelEmailAddress From { get; set; }
        [Category("Credentials"), ModelBrowsable(typeof(ModelSmtpClientUseDefaultCredentialsVisibilityCalculator)), Required(typeof(ModelSmtpClientDeliveryMethodRequiredCalculator))]
        IModelEmailAddress UserName { get; set; }
apobekiaris commented 1 year ago

in the same file u see

if (smtpClient.DeliveryMethod == SmtpDeliveryMethod.Network){
                smtpClient.Host = modelSmtpClient.Host;
                smtpClient.Port = modelSmtpClient.Port;
                smtpClient.EnableSsl = modelSmtpClient.EnableSsl;
                smtpClient.UseDefaultCredentials = modelSmtpClient.UseDefaultCredentials;
                if (!smtpClient.UseDefaultCredentials){
                    smtpClient.Credentials = new NetworkCredential(modelSmtpClient.UserName.Address,
                        modelSmtpClient.Password);
                }
            }

so UseDefaultCredentials is only used SmtpDeliveryMethod.Network else it has no effect. Does this makes sense?

yunits commented 1 year ago

yes that makes sense and looks right.

My problem is, that the property UserName will not be filled/populated with "IModelEmailAddress" entries. It is just empty and you cannot choose any EMail address. And if you don't choose an address, you will get validation error.

image

apobekiaris commented 1 year ago

https://user-images.githubusercontent.com/159464/253209132-db091a24-b7f1-48f5-b924-38e48784c7b0.png

do u have entries in the EmailAddresses

yunits commented 1 year ago

yes. You also see that I can choose my test address in From Property.

image

I still think that "[DataSourceProperty(nameof(FromEmails))]" is missing above IModelEmailAddress UserName { get; set; }?

apobekiaris commented 1 year ago

ah now i got it apologies, anyways I will push asap,in the meantime u may try to override it with something like

[ModelDisplayName("SmtpClient")]
    public interface IModelEmailSmtpClientEx : IModelNode {
        [DataSourceProperty("Emails")]
        [Category("Credentials"), ModelBrowsable(typeof(ModelSmtpClientUseDefaultCredentialsVisibilityCalculator)), Required(typeof(ModelSmtpClientDeliveryMethodRequiredCalculator))]
        new IModelEmailAddress UserName { get; set; }
    }

extend the IModelEmailSmtpClient

this I wrote on foot and did not test but I use similar approaches in the code so somehow near it is possible to override note the new

apobekiaris commented 1 year ago

or u can simply add it in your xafml file manuly the restriction is UI only think the code will read it even if there are no entries in the lookup

yunits commented 1 year ago

Thanks, no hurry. I will wait until you have time for it.

apobekiaris commented 1 year ago

The pre-release 4.231.1.0 in the Reactive.XAF lab branch includes commits that relate to this task:

1011](https://github.com/eXpandFramework/Reactive.XAF/commit/e254d34e962230e21f155e6b3013bcc001c2deb7)

To minimize version conflicts we recommend that you use the Xpand.XAF.Core.All, Xpand.XAF.Win.All, Xpand.XAF.Web.All packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Released packages: Xpand.Extensions v.4.231.2
Xpand.Extensions.Blazor v.4.231.2
Xpand.Extensions.Mono.Cecil v.4.231.2
Xpand.Extensions.Office.Cloud v.4.231.2
Xpand.Extensions.Office.Cloud.Google.Blazor v.4.231.2
Xpand.Extensions.Reactive v.4.231.2
Xpand.Extensions.XAF v.4.231.2
Xpand.Extensions.XAF.Xpo v.4.231.2
Xpand.TestsLib v.4.231.2
Xpand.TestsLib.Blazor v.4.231.2
Xpand.TestsLib.Common v.4.231.2
Xpand.TestsLib.EasyTest v.4.231.2
Xpand.VersionConverter v.4.231.2
Xpand.XAF.Core.All v.4.231.2
Xpand.XAF.Modules.AutoCommit v.4.231.2
Xpand.XAF.Modules.Blazor v.4.231.2
Xpand.XAF.Modules.BulkObjectUpdate v.4.231.2
Xpand.XAF.Modules.CloneMemberValue v.4.231.2
Xpand.XAF.Modules.CloneModelView v.4.231.2
Xpand.XAF.Modules.Email v.4.231.2
Xpand.XAF.Modules.GridListEditor v.4.231.2
Xpand.XAF.Modules.HideToolBar v.4.231.2
Xpand.XAF.Modules.JobScheduler.Hangfire v.4.231.2
Xpand.XAF.Modules.JobScheduler.Notification v.4.231.2
Xpand.XAF.Modules.MasterDetail v.4.231.2
Xpand.XAF.Modules.ModelMapper v.4.231.2
Xpand.XAF.Modules.ModelViewInheritance v.4.231.2
Xpand.XAF.Modules.Office.Cloud.Google v.4.231.2
Xpand.XAF.Modules.Office.Cloud.Google.Calendar v.4.231.2
Xpand.XAF.Modules.Office.Cloud.Google.Tasks v.4.231.2
Xpand.XAF.Modules.Office.DocumentStyleManager v.4.231.2
Xpand.XAF.Modules.OneView v.4.231.2
Xpand.XAF.Modules.PositionInListView v.4.231.2
Xpand.XAF.Modules.ProgressBarViewItem v.4.231.2
Xpand.XAF.Modules.RazorView v.4.231.2
Xpand.XAF.Modules.Reactive v.4.231.2
Xpand.XAF.Modules.Reactive.Logger v.4.231.2
Xpand.XAF.Modules.Reactive.Logger.Client.Win v.4.231.2
Xpand.XAF.Modules.Reactive.Logger.Hub v.4.231.2
Xpand.XAF.Modules.Reactive.Rest v.4.231.2
Xpand.XAF.Modules.RefreshView v.4.231.2
Xpand.XAF.Modules.SequenceGenerator v.4.231.2
Xpand.XAF.Modules.Speech v.4.231.2
Xpand.XAF.Modules.SpellChecker v.4.231.2
Xpand.XAF.Modules.StoreToDisk v.4.231.2
Xpand.XAF.Modules.SuppressConfirmation v.4.231.2
Xpand.XAF.Modules.TenantManager v.4.231.2
Xpand.XAF.Modules.ViewEditMode v.4.231.2
Xpand.XAF.Modules.ViewItemValue v.4.231.2
Xpand.XAF.Modules.ViewWizard v.4.231.2
Xpand.XAF.Modules.Windows v.4.231.2
Xpand.XAF.Web.All v.4.231.2
Xpand.XAF.Win.All v.4.231.2

Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.

If you do not use these packages directly but through a module of the main eXpandFramework project, please wait for the bot to notify you again when integration is finished or update the related packages manually.

Thanks a lot for your contribution.

expand commented 8 months ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.