Closed beneton2003 closed 8 months ago
I have custom implemented ApplicationUser class, maybe this is the problem?:
namespace HRStation.Module.BusinessObjects.Security;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Net.Mail;
using System.Reactive.Linq;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Security;
using DevExpress.Persistent.BaseImpl.EF.PermissionPolicy;
[DefaultProperty(nameof(UserName))]
public class ApplicationUser : PermissionPolicyUser, ISecurityUserWithLoginInfo
{
public ApplicationUser() : base()
{
UserLogins = new ObservableCollection<ApplicationUserLoginInfo>();
}
[Browsable(false)]
[Aggregated]
public virtual IList<ApplicationUserLoginInfo> UserLogins { get; set; }
IEnumerable<ISecurityUserLoginInfo> IOAuthSecurityUser.UserLogins => UserLogins.OfType<ISecurityUserLoginInfo>();
ISecurityUserLoginInfo ISecurityUserWithLoginInfo.CreateUserLoginInfo(string loginProviderName, string providerUserKey)
{
ApplicationUserLoginInfo result = ((IObjectSpaceLink)this).ObjectSpace.CreateObject<ApplicationUserLoginInfo>();
result.LoginProviderName = loginProviderName;
result.ProviderUserKey = providerUserKey;
result.User = this;
return result;
}
}
I have also nonpersistent object in my project:
namespace HRStation.Module.BusinessObjects.Worklogs;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.Validation;
using HRStation.Module.BusinessObjects.Issues;
using HRStation.Module.BusinessObjects.Persons;
using HRStation.Module.BusinessObjects.Security;
using HRStation.Module.BusinessObjects.Sprints;
[DomainComponent]
[RuleCriteria("WorklogNPO_EndOn", DefaultContexts.Save, "EndOn > StartOn", "End On shoulde greater than Start On")]
public class WorklogActionNPO : NonPersistentObjectImpl, IObjectSpaceLink, INotifyPropertyChanged
{
#region Private fields
private Person person;
private Project project;
private ProjectAction projectAction;
private Issue issue;
private Sprint sprint;
private DateTime startOn;
private int durationHours;
private int durationMinutes;
private string description;
//private IObjectSpace objectSpace;
#endregion
public override void OnCreated()
{
ApplicationUser currentUser = ObjectSpace.GetObjectByKey<ApplicationUser>(SecuritySystem.CurrentUserId);
Person = ObjectSpace.FirstOrDefault<Person>(p => p.ApplicationUser == currentUser);
Sprint = ObjectSpace.FirstOrDefault<SprintIssue>(s => s.Person == Person)?.Sprint;
base.OnCreated();
}
[RuleRequiredField]
public Person Person
{
get { return person; }
set { SetPropertyValue(ref person, value); }
}
[RuleRequiredField]
public Project Project
{
get { return project; }
set
{
ProjectAction = null;
Issue = null;
SetPropertyValue(ref project, value);
}
}
[RuleRequiredField]
[DataSourceProperty("Project.ProjectActions")]
public ProjectAction ProjectAction {
get
{
return projectAction;
}
set
{
Issue = value?.Issue;
SetPropertyValue(ref projectAction, value);
}
}
public Issue Issue
{
get { return issue; }
set { SetPropertyValue(ref issue, value); }
}
[RuleRequiredField]
public Sprint Sprint
{
get { return sprint; }
set { SetPropertyValue(ref sprint, value); }
}
public DateTime StartOn
{
get { return startOn; }
set { SetPropertyValue(ref startOn, value); }
}
public DateTime EndOn { get { return StartOn.AddHours(DurationHours).AddMinutes(DurationMinutes); } }
[RuleValueComparison("WorklogNPO_DurationHoursMax", DefaultContexts.Save, ValueComparisonType.LessThanOrEqual, 24)]
[RuleValueComparison("WorklogNPO_DurationHoursMin", DefaultContexts.Save, ValueComparisonType.GreaterThanOrEqual, 0)]
public int DurationHours
{
get { return durationHours; }
set { SetPropertyValue(ref durationHours, value); }
}
[RuleValueComparison("WorklogNPO_DurationMinutesMax", DefaultContexts.Save, ValueComparisonType.LessThanOrEqual, 59)]
[RuleValueComparison("WorklogNPO_DurationMinutesMin", DefaultContexts.Save, ValueComparisonType.GreaterThanOrEqual, 0)]
public int DurationMinutes
{
get { return durationMinutes; }
set { SetPropertyValue(ref durationMinutes, value); }
}
public string Description
{
get { return description; }
set { SetPropertyValue(ref description, value); }
}
}
Can you please post a sample.
Reference i
https://github.com/beneton2003/HRStationXaf - i added you to my project, so you can see the whole solution.
thnks I will test the case, I also interested to know if you plan to work with the REST module or you face problems cause you install it together with the all the packages
I want to use REST feature, maybe i installed something wrong. Sorry i am not very experienced. I will be very happy if you give me some advice how to fix it, i also have a question about authentification, how to use bearer token for the requests? Maybe you have some example of the working with some public api?
I want to get recipient accounts from this api: https://docs.wise.com/api-docs/api-reference/recipient
thnks for the clarification, now I see the problem without to explore your solution
Castle.Proxies.ApplicationUserProxy
meaning you are in EF and the package uses XPO. Note the package is tested for various cases in https://github.com/eXpandFramework/Reactive.XAF/tree/master/src/Tests/Reactive.Rest. Consider exploring them to get how the package works if you plan to use XPO instead
thnks for the clarification, now I see the problem without to explore your solution
Castle.Proxies.ApplicationUserProxy
meaning you are in EF and the package uses XPO. Note the package is tested for various cases in https://github.com/eXpandFramework/Reactive.XAF/tree/master/src/Tests/Reactive.Rest. Consider exploring them to get how the package works if you plan to use XPO instead
I am using both xpo and EF. I have Hangfire module installed and used XPO, maybe i just can add this module to that part which using XPO?
But when i tried to include this module in the part which uses xpo, its still getting this error... i will explore more
I realise that Reactive.rest somehow uses the Security system (like PermissionPolicyUser), but i am using my security system in EF and maybe this is the reason....
Not exactly
Unable to cast object of type 'Castle.Proxies.ApplicationUserProxy' to type 'Xpand.XAF.Modules.Reactive.Rest.ICredentialBearer'.
it speaks out, meaning u imlpement ICredentialBearer in your ApplicationUser which is an EF Entity
the package may be able to work even with EF (I never try it) given that ICrendentialBearer is not an EF entity, or they maybe other problems in regards to EF, I really not sure as this was designed with XPO
Closing issue for age. Feel free to reopen it at any time.
.Thank you for your contribution.
๐ค๐๐ฒ๐๐๐ถ๐ผ๐ป Hi! Maybe somebody can help me with some strange issue. This is the full log
Log:
================================================================================ The error occurred: