using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.ServiceProcess;
using System.Timers;
namespace FingerPrintService
{
// Token: 0x02000002 RID: 2
public class FingerPrintDaily : ServiceBase
{
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
public FingerPrintDaily()
{
this.InitializeComponent();
}
// Token: 0x06000002 RID: 2 RVA: 0x0000206C File Offset: 0x0000026C
protected override void OnStart(string[] args)
{
this.timer_fingerprint.Start();
using (StreamWriter file = new StreamWriter("C:\\finger.txt", true))
{
file.WriteLine("service started " + DateTime.Now.ToString());
}
}
// Token: 0x06000003 RID: 3 RVA: 0x000020DC File Offset: 0x000002DC
protected override void OnStop()
{
}
// Token: 0x06000004 RID: 4 RVA: 0x000020E0 File Offset: 0x000002E0
private void timer_fingerprint_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
SqlConnection Con_Actatek = new SqlConnection("Server=192.168.0.115;Database=myActatek;User ID=sa;Password=****");
SqlCommand cmd_Actatek = new SqlCommand("SelectNewRecords");
cmd_Actatek.Connection = Con_Actatek;
cmd_Actatek.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adp_Actatek = new SqlDataAdapter(cmd_Actatek);
DataTable dt_Actatek = new DataTable();
DataTable dt_Location = new DataTable();
adp_Actatek.Fill(dt_Actatek);
cmd_Actatek.CommandText = "SelectLocation";
adp_Actatek.Fill(dt_Location);
SqlCommand cmd_Update_Actatek = new SqlCommand("UpdateTrans");
cmd_Update_Actatek.CommandType = CommandType.StoredProcedure;
cmd_Update_Actatek.Connection = Con_Actatek;
SqlConnection Con_hadir = new SqlConnection("Server=192.168.0.206;Database=HadirDB;User=sa;Password=****");
SqlCommand cmd_hadir2 = new SqlCommand("InsertProcessQueue");
SqlCommand cmd_hadir3 = new SqlCommand("InsertNewRecordHadir");
cmd_hadir3.Connection = Con_hadir;
cmd_hadir2.Connection = Con_hadir;
cmd_hadir2.CommandType = CommandType.StoredProcedure;
cmd_hadir3.CommandType = CommandType.StoredProcedure;
Con_hadir.Open();
Con_Actatek.Open();
for (int i = 0; i < dt_Actatek.Rows.Count; i++)
{
cmd_hadir3.Parameters.Clear();
cmd_hadir2.Parameters.Clear();
cmd_hadir3.Parameters.AddWithValue("@EMPLOYEEID", dt_Actatek.Rows[i]["USERID"].ToString());
cmd_hadir3.Parameters.AddWithValue("@DateTime", DateTime.Parse(dt_Actatek.Rows[i]["ActionDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss"));
cmd_hadir3.Parameters.AddWithValue("@Type", dt_Actatek.Rows[i]["EVENTID"].ToString());
cmd_hadir2.Parameters.AddWithValue("@userid", dt_Actatek.Rows[i]["USERID"].ToString());
cmd_hadir2.Parameters.AddWithValue("@date", DateTime.Parse(dt_Actatek.Rows[i]["ActionDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss"));
string LocationID = "";
for (int ii = 0; ii < dt_Location.Rows.Count; ii++)
{
if (dt_Location.Rows[ii]["LocationIP"].ToString() == dt_Actatek.Rows[i]["TERMINALIP"].ToString())
{
LocationID = dt_Location.Rows[ii]["Flag"].ToString();
}
}
cmd_hadir3.Parameters.AddWithValue("@LocationID", LocationID);
try
{
int RowEf = cmd_hadir3.ExecuteNonQuery();
try
{
int RowEf2 = cmd_hadir2.ExecuteNonQuery();
}
catch
{
}
}
catch (Exception ee)
{
using (StreamWriter file = new StreamWriter("C:\\finger.txt", true))
{
file.WriteLine(ee.ToString());
}
}
cmd_Update_Actatek.Parameters.Clear();
cmd_Update_Actatek.Parameters.AddWithValue("@ID", dt_Actatek.Rows[i]["ID"].ToString());
cmd_Update_Actatek.ExecuteNonQuery();
}
Con_hadir.Close();
Con_Actatek.Close();
}
catch (Exception ee)
{
}
}
// Token: 0x06000005 RID: 5 RVA: 0x000024D0 File Offset: 0x000006D0
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
{
this.components.Dispose();
}
base.Dispose(disposing);
}
// Token: 0x06000006 RID: 6 RVA: 0x00002508 File Offset: 0x00000708
private void InitializeComponent()
{
this.timer_fingerprint = new Timer();
((ISupportInitialize)this.timer_fingerprint).BeginInit();
this.timer_fingerprint.Enabled = true;
this.timer_fingerprint.Interval = 30000.0;
this.timer_fingerprint.Elapsed += this.timer_fingerprint_Elapsed;
base.ServiceName = "Service1";
((ISupportInitialize)this.timer_fingerprint).EndInit();
}
// Token: 0x04000001 RID: 1
private IContainer components = null;
// Token: 0x04000002 RID: 2
private Timer timer_fingerprint;
}
}