0
good afternoon I am wanting to create a billing email sending rule that when there is a holiday he considers the next day and if it is Sunday he performs the task on Tuesday. Today the system uses a bank where it checks the Customers who are with the account situation to receive in open and our system in ERP and sends an e-mail warning after a certain time of days of delay, but on the days falling on holidays I wanted to add one more day not to generate the charge on it.
I’m using a code I picked up on a forum but it doesn’t load the dates as true or false
public static class testeferiado
{
public static DateTime Holiday(DateTime data)
{
while (true)
{
if (Feriado(data))
{
if (data.DayOfWeek == DayOfWeek.Sunday)
{
data = data.AddDays(2);
}
data = data.AddDays(1);
return Holiday(data);
}
return data;
}
}
readonly static SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
static SqlCommand command = new SqlCommand();
static string result;
public static bool Feriado(DateTime dt)
{
command.CommandText = "select * from [mia].dbo.feriado where dtferiado = '" + dt.ToString("dd/MM/yyyy") + "'";
con.Open();
command.Connection = con;
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
return true;
}
else
{
return false;
}
}
}
}
And then a code to perform the check, where I use Quartz and at that moment I can’t make him understand the day in Checkhelper.Holiday(),
public class ScheduleHelper : IJob
{
public void Execute(IJobExecutionContext context)
{
//Delimita o tempo de execução até às 18h
if (DateTime.Now.Hour < 18)
{
if (DateTime.Today == CheckHelper.Holiday())
{
//Se horário é = 12h aplica-se a régua do setor financeiro
if (DateTime.Now.Hour == 10 && DateTime.Now.Minute == 55)
{
//Se o dia da semana for = terça feira é necessário checar envios agendados
if (DateTime.Today.DayOfWeek == DayOfWeek.Tuesday)
{
CheckHelper.CheckEnviosAgendados();
}
CheckHelper.CheckReguaFiananceiro();
}
}
}
I believe that your tip will help me a lot, but I leave a log in the bank to send the next day
– Wesley Henrique