C
C#17mo ago
Lyakabynka

❔ Hangfire: Guid instead of Int BackgroundJob.Schedule

21 Replies
RazorSharpFang
RazorSharpFang17mo ago
Is BackgroundJobClient your class that you wrote?
Lyakabynka
LyakabynkaOP17mo ago
No, I inject IBackgroundJobClient in MediatorHandler in this case
Lyakabynka
LyakabynkaOP17mo ago
Jimmacle
Jimmacle17mo ago
so your problem is that hangfire identifies jobs with integers instead of guids?
Lyakabynka
LyakabynkaOP17mo ago
yes
Jimmacle
Jimmacle17mo ago
why do you think it's not giving you unique IDs? because it is
RazorSharpFang
RazorSharpFang17mo ago
You could add another table that associates integers with guids when
Lyakabynka
LyakabynkaOP17mo ago
It is giving, but I need to pass it to the function before the output from .Schedule method returns
Jimmacle
Jimmacle17mo ago
it doesn't have an ID until you schedule it
Lyakabynka
LyakabynkaOP17mo 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
Jimmacle17mo ago
i'm still not understanding the problem are you using hangfire generated IDs or your own IDs?
Lyakabynka
LyakabynkaOP17mo 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
Jimmacle17mo ago
what if you just make the job check if the request still exists, and do nothing if it doesn't
Lyakabynka
LyakabynkaOP17mo ago
I dont get it (
Jimmacle
Jimmacle17mo ago
i would assume your mediatr handler already has error handling for invalid plans
Lyakabynka
LyakabynkaOP17mo ago
One sec
Lyakabynka
LyakabynkaOP17mo ago
Lyakabynka
LyakabynkaOP17mo 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
LyakabynkaOP17mo ago
I did it like this, but if someone has a better solution ( make Hangfire return guid or smth ) please, help me.
Lyakabynka
LyakabynkaOP17mo 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
Accord17mo 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