static void Main(string[] args) { var seriLog = new ApplicationLogGenerator.SchedulerSerilogs(); AccessDBReader.InitLogger(seriLog); AttendanceManager.InitLogger(seriLog); AccessDBReader.Read(); AttendanceManager.LoadToMongoDB(); Console.ReadLine(); }
static void Main(string[] args) { AccessDBReader.Read(); //var accessPoints = JsonConvert.SerializeObject(AttendanceManager.AccessPoints, Formatting.Indented); //System.IO.File.WriteAllText(@"C:\Temp\Attendance\AccessPoints.txt", accessPoints); //var employees = JsonConvert.SerializeObject(AttendanceManager.Employees, Formatting.Indented); //System.IO.File.WriteAllText(@"C:\Temp\Attendance\Employees.txt", employees); var accessEvents = JsonConvert.SerializeObject(AttendanceManager.AccessEvents, Formatting.Indented); System.IO.File.WriteAllText(@"C:\Temp\Attendance\AccessEvents.txt", accessEvents); AttendanceManager.LoadToMongoDB(); //AttendanceManager.LoadUsersToDB(); }
static public void ReadAccessEventLogsForMonth(int month, int year) { var tableName = "DeviceLogs_" + month.ToString() + "_" + year.ToString(); if (!TableExists(tableName)) { return; } OleDbCommand command = new OleDbCommand(); command.Connection = _accessDBconnection; command.CommandText = "select DeviceId,UserId,LogDate,DeviceLogId from " + tableName; OleDbDataAdapter da = new OleDbDataAdapter(command); DataTable dt = new DataTable(); da.Fill(dt); DataColumn UserId = dt.Columns["UserId"]; DataColumn DeviceId = dt.Columns["DeviceId"]; DataColumn LogDate = dt.Columns["LogDate"]; DataColumn DeviceLogId = dt.Columns["DeviceLogId"]; List <AccessEvent> accessEvents = new List <AccessEvent>(); foreach (DataRow row in dt.Rows) { AccessEvent d = new AccessEvent(); var useId = int.Parse(row[UserId].ToString()); var employee = AttendanceManager.EmployeeById(useId); if (employee == null) { continue; } d.EmployeeID = employee.ID; d.EmployeeFirstName = employee.FirstName; d.EmployeeLastName = employee.LastName; var accessPoint = AttendanceManager.AccessPointById(int.Parse(row[DeviceId].ToString())); d.AccessPointID = accessPoint.ID; d.AccessPointName = accessPoint.Name; d.AccessPointIPAddress = accessPoint.IpAddress; var dtString = row[LogDate].ToString().Trim(); var tokens = dtString.Split(new char[] { ' ', '-', ':' }); var ye = int.Parse(tokens[2]); var mo = int.Parse(tokens[1]); var dy = int.Parse(tokens[0]); var h = int.Parse(tokens[3]); var m = int.Parse(tokens[4]); var s = int.Parse(tokens[5]); d.EventTime = new DateTime(ye, mo, dy, h, m, s); var deviceLogId = row[DeviceLogId].ToString(); var y = ye.ToString().Substring(2); var idStr = d.AccessPointID.ToString() + y + mo.ToString() + deviceLogId; var logId = int.Parse(idStr); d.ID = logId; accessEvents.Add(d); } var monthlyLog = new MonthlyAccessLog(); monthlyLog.Month = new DateTime(year, month, 1); monthlyLog.AccessEvents = accessEvents; AttendanceManager.MonthlyAccessLogs.Add(monthlyLog); }