약속을 예약하는 컨트롤러 메서드가 있습니다. 나는 약속을하기 전에 서비스에 로그인하기 위해 5 분 전에 SMS (twilio)를 통해 사용자에게 상기시키는 작업을 계획하고있다. 여기 Hang Fire에서 전화 걸기가 어려움
내 메서드 호출입니다 :private SMSNotifier sms = new SMSNotifier();
BackgroundJob.Schedule(() => sms.SendPatientUpcomingApptNotificationTest(appointment), appointment.Start.AddMinutes(-5));
여기 내 클래스 :
public SMSNotifier()
{
var accountSid = ConfigurationManager.AppSettings["TwilioSid"];
// Your Auth Token from twilio.com/console
var authToken = ConfigurationManager.AppSettings["TwilioToken"]; ;
TwilioClient.Init(accountSid, authToken);
}
public void SendPatientUpcomingApptNotificationTest(Appointment appt)
{
var message = MessageResource.Create(
to: new PhoneNumber("+xxxxxxxxxx"),
from: new PhoneNumber("+xxxxxxxxxx"),
body: string.Format("Hello {0} {1}! You have an upcoming web based video appointment with xxxxxxxxxx. Please login to the website to be seen. Your appointment time is: {2} Thank you - xxxxxxxx", "xxxxxxx", "xxxxxxxx", appt.Start));
}
}
나는이 오류가 계속 :
Server Error in '/' Application.
Self referencing loop detected for property 'User' with type 'System.Data.Entity.DynamicProxies.AspNetUser_80E6332CC002F8FCF589159A68E74A0922BEE992586B9FE280D950E149CCC7EB'. Path 'Patient.ActiveSessions[0]'.
하지만 난 그냥 이해가 안 돼요 왜. 어디서나 User 객체를 참조하지 않습니다.
나는 분명히 그 오류 봤 언급해야한다:
아무도 제공하지 않는 y 진행. 나는 여전히 같은 오류가있다.
너희들은 어떻게 생각하니?
확실히 'SendPatientUpcomingApptNotificationTest'메소드를 예약하려는 방식과 관련이 있다고 생각합니다. Console.WriteLine을 할 수 있으며 작업을 대기열에 넣을 수 있습니다.
IE : 당신의 appointment
객체를 직렬화하려고 할 때이 오류로 실행중인 같은
BackgroundJob.Schedule(() => Console.WriteLine("TestSchedule"), appointment.Start.AddMinutes(-5));
가 작동
완벽
감사합니다. Peter, 매우 도움이됩니다. 문제없이 대기업에 대기시킬 수있는 것 같습니다. 내 다른 질문은, SMSNotifier 클래스에 대한 생성자가 제대로 실행 되나요? 여전히 HangFire 콘솔에서 null 참조 오류가 발생합니다. 하지만 수동으로 SendPatientUpcomingApptNotificationTest 메서드를 실행할 때 제대로 작동합니다. 이상한가? – Waragi
내 편이 맘에 안 든다. 피터, 고마워! – Waragi