Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobScheduler.Hangfire.Notification System.InvalidCastException #1045

Open
ricardoamm opened this issue Feb 2, 2024 · 7 comments
Open

JobScheduler.Hangfire.Notification System.InvalidCastException #1045

ricardoamm opened this issue Feb 2, 2024 · 7 comments
Labels

Comments

@ricardoamm
Copy link

Exception occurs after trigger Execute Action Job :

System.InvalidCastException
HResult=0x80004002
Message=Unable to cast object of type 'Xpand.XAF.Modules.JobScheduler.Hangfire.BusinessObjects.ExecuteActionJob' to type 'Xpand.XAF.Modules.JobScheduler.Hangfire.Notification.BusinessObjects.ObjectStateNotification'.
Source=Xpand.XAF.Modules.JobScheduler.Notification
StackTrace:
at Xpand.XAF.Modules.JobScheduler.Hangfire.Notification.NotificationService.<>c__DisplayClass4_0.b__1(IObjectSpace objectSpace) in C:\Users\ricardo\Desktop\grupolc_sigo\JobScheduler.Notification\NotificationService.cs:line 58
at System.Reactive.Linq.ObservableImpl.Using2._.Run(Using2 parent)

image

@apobekiaris
Copy link
Member

the JobNotification test currently are on refactoring, so they cannot validate that at least on the tested scenario they work. In any case without a sample and detailed steps on how to repro I cannot help mych

@ricardoamm
Copy link
Author

I just configure a Execute Action Job, save one object in detail view and then force the trigger.

@apobekiaris
Copy link
Member

sample please

@ricardoamm
Copy link
Author

I'm working on a big project, and it's hard to me right now isolate same parts.
I'm checking several notification approaches.

About this situation i bypass it validating the Object Type in the Notificaton Module:

internal static IObservable<Unit> JobNotification(this BlazorApplication application, string workerId) => Observable.Using(() => application.CreateNonSecuredObjectSpace(typeof(JobWorker)), objectSpace => { var jobWorker = objectSpace.GetObjectsQuery<JobWorker>().FirstOrDefault(job => job.Id == workerId); if (jobWorker != null) { if (jobWorker.Job is ObjectStateNotification job) {

I have one last question regarding the creation of Object State Notification, and it's why some Objects are not available to select in the Object Lookup. Curiously are the same as what I want.

@apobekiaris
Copy link
Member

a lot can happen when u validate the problem against your big project and my resources are also very limited, that's why a sample is always the only way to go.

your last question is unclear to me best guess you need to see how the objects populate

 [DataSourceProperty(nameof(Objects))]
        [ValueConverter(typeof(ObjectTypeValueConverter))]
        [Persistent][RuleRequiredField]
        public ObjectType Object {
            get => _object;
            set => SetPropertyValue(nameof(Object), ref _object, value);
        }

        [Browsable(false)]
        public IList<ObjectType> Objects 
            => ((IModelJobSchedulerNotification)CaptionHelper.ApplicationModel
                    .ToReactiveModule<IModelReactiveModulesJobScheduler>().JobScheduler).Notification.Types
                .Select(type => new ObjectType(type.Type.TypeInfo.Type) {Name = type.Type.Caption}).ToArray();

@ricardoamm
Copy link
Author

ricardoamm commented Feb 2, 2024

Once again thank you for your support.
I have this attributes in one object not listed:

image

@apobekiaris
Copy link
Member

@apobekiaris apobekiaris removed their assignment Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants