eXpand icon indicating copy to clipboard operation
eXpand copied to clipboard

JobScheduler.Hangfire.Notification System.InvalidCastException

Open ricardoamm opened this issue 1 year ago • 7 comments

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.<JobNotification>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

ricardoamm avatar Feb 02 '24 09:02 ricardoamm

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

apobekiaris avatar Feb 02 '24 09:02 apobekiaris

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

ricardoamm avatar Feb 02 '24 09:02 ricardoamm

sample please

apobekiaris avatar Feb 02 '24 09:02 apobekiaris

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.

ricardoamm avatar Feb 02 '24 10:02 ricardoamm

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();

apobekiaris avatar Feb 02 '24 10:02 apobekiaris

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

image

ricardoamm avatar Feb 02 '24 11:02 ricardoamm

there are detailed docs https://github.com/eXpandFramework/Reactive.XAF/tree/master/src/Modules/JobScheduler.Notification

is your type there?

apobekiaris avatar Feb 02 '24 14:02 apobekiaris