eXpandFramework / eXpand

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

JobScheduler.Hangfire.Notification System.InvalidCastException #1045

Open ricardoamm opened 7 months ago

ricardoamm commented 7 months ago

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\grupolcsigo\JobScheduler.Notification\NotificationService.cs:line 58 at System.Reactive.Linq.ObservableImpl.Using`2..Run(Using`2 parent)

image

apobekiaris commented 7 months ago

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 commented 7 months ago

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

apobekiaris commented 7 months ago

sample please

ricardoamm commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

image

apobekiaris commented 7 months ago

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

is your type there?