C
C#12mo ago
Lyakabynka

❔ Hangfire: Guid instead of Int BackgroundJob.Schedule

21 Replies
RazorSharpFang
RazorSharpFang12mo ago
Is BackgroundJobClient your class that you wrote?
Lyakabynka
Lyakabynka12mo ago
No, I inject IBackgroundJobClient in MediatorHandler in this case
Lyakabynka
Lyakabynka12mo ago
Jimmacle
Jimmacle12mo ago
so your problem is that hangfire identifies jobs with integers instead of guids?
Lyakabynka
Lyakabynka12mo ago
yes
Jimmacle
Jimmacle12mo ago
why do you think it's not giving you unique IDs? because it is
RazorSharpFang
RazorSharpFang12mo ago
You could add another table that associates integers with guids when
Lyakabynka
Lyakabynka12mo ago
It is giving, but I need to pass it to the function before the output from .Schedule method returns
Jimmacle
Jimmacle12mo ago
it doesn't have an ID until you schedule it
Lyakabynka
Lyakabynka12mo ago
As it is described in the posted screenshoot, I need to pass ID of the scheduledplan to the PlanTransmissionRequested object but its impossible when dealing with ints database-generated i meant
Jimmacle
Jimmacle12mo ago
i'm still not understanding the problem are you using hangfire generated IDs or your own IDs?
Lyakabynka
Lyakabynka12mo ago
Okay, lemme describe again. I want to use Guid as ID for my entire project. When user is scheduling notification on specific time, it is added to my OWN database ( ScheduledJob -> described in the post ). Once it is invoked, this ScheduledJob should be deleted from the database as it is no longer active ( executed ). That is why I need to pass a scheduled job id to the PlanTransmissionRequested object ( see post )
Jimmacle
Jimmacle12mo ago
what if you just make the job check if the request still exists, and do nothing if it doesn't
Lyakabynka
Lyakabynka12mo ago
I dont get it (
Jimmacle
Jimmacle12mo ago
i would assume your mediatr handler already has error handling for invalid plans
Lyakabynka
Lyakabynka12mo ago
One sec
Lyakabynka
Lyakabynka12mo ago
Lyakabynka
Lyakabynka12mo ago
I hope it helps On the last screenshot I would delete executed active ScheduledJob from my database It would be perfect if I could pass my own id to the .Schedule method, but unfortunately as I pass in .AddOrUpdate
Lyakabynka
Lyakabynka12mo ago
I did it like this, but if someone has a better solution ( make Hangfire return guid or smth ) please, help me.
Lyakabynka
Lyakabynka12mo ago
as nobody replied, I made it the easiest way I found out -> https://github.com/Lyakabynka/PlanIt/ if somebody is interested
GitHub
GitHub - Lyakabynka/PlanIt
Contribute to Lyakabynka/PlanIt development by creating an account on GitHub.
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts