45 lines
1.8 KiB
C#
45 lines
1.8 KiB
C#
|
using HRM.BO;
|
|||
|
using HRM.DA;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
|
|||
|
namespace HRM.AttendanceAutoProcess
|
|||
|
{
|
|||
|
class Program
|
|||
|
{
|
|||
|
static void Main(string[] args)
|
|||
|
{
|
|||
|
AttendanceAutoProcessConfiguration oAttendanceAutoProcessConfiguration = new AttendanceAutoProcessConfiguration();
|
|||
|
StreamWriter ofile = null;
|
|||
|
string basepath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|||
|
string loc = basepath + "\\log.txt";
|
|||
|
|
|||
|
if(!File.Exists(loc))
|
|||
|
{
|
|||
|
File.Create(loc).Dispose();
|
|||
|
}
|
|||
|
|
|||
|
var configurationBuilder = new ConfigurationBuilder().SetBasePath(basepath).AddJsonFile("appsettings.json").Build();
|
|||
|
configurationBuilder.GetSection("AttendanceAutoProcess").Bind(oAttendanceAutoProcessConfiguration);
|
|||
|
|
|||
|
DateTime processDate = DateTime.Today.AddDays(-oAttendanceAutoProcessConfiguration.NumberOfDaysToProcess).Date;
|
|||
|
try
|
|||
|
{
|
|||
|
new AttendanceProcess().Process(processDate, EnumProcessMode.Auto, oAttendanceAutoProcessConfiguration.PayrollTypeForAutoAttendanceProcess, 1);
|
|||
|
|
|||
|
ofile = new StreamWriter(loc, true);
|
|||
|
ofile.WriteLine("Date & Time : {0}, Attendence Process Completed Successfully For {1}.", DateTime.Now.ToString(), processDate.ToString("dd MMM yyyy"));
|
|||
|
ofile.Close();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
ofile = new StreamWriter(loc, true);
|
|||
|
ofile.WriteLine("Date & Time : {0}, Error While Processing Attendence Data For {1}, Reason: {2}.", DateTime.Now.ToString(), processDate.ToString("dd MMM yyyy"), ex.Message);
|
|||
|
ofile.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|