Hi Everybody,
I’m using HF v.1.6.12 with RestSharp ,and I got problem about passing Parameter between job.
Can anyone give me a suggestion? How to use “client” again in GetTransaction method?
by this code it always null.
Code
public class BankService
{
public RestClient client;
public BankService()
{
}
public void Login()
{
this.client = new RestClient();
this.client.BaseUrl = new Uri(" Login Url ");
this.client.CookieContainer = new System.Net.CookieContainer();
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "data", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
logging("Login");
}
public void GetTransactions()
{
logging("BEGIN GetTransactions");
this.client.BaseUrl = new Uri("Request Url");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
logging("Check Transactions");
if (!response.Content.Contains("NO TRANSACTION"))
{
logging("BEGIN Process");
FullProcess(response);
}
else
{
logging("NO TRANSACTIONS");
}
}
}
Job
Bank bank = new Bank(); BackgroundJob.Enqueue(() => bank.Login()); RecurringJob.AddOrUpdate(() => bank.GetTransactions(), Cron.MinuteInterval(5));
Thankyou