//To read the attendence logs (For TFT screen devices,Filename:DeviceID_attolog.dat) private void btnSSRAttLogRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength;//length of the bytes to get from the data string sPIN2 = ""; string sVerified = ""; string sTime_second = ""; string sDeviceID = ""; string sStatus = ""; string sWorkcode = ""; openFileDialog1.Filter = "1_attlog(*.dat)|*.dat"; openFileDialog1.FileName = "1_attlog.dat";//1 stands for one possible deviceid if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); lvSSRAttLog.Items.Clear(); int iStartIndex = 0; int iOneLogLength;//the length of one line of attendence log for (int i = iStartIndex; i < iLength; i++) { if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10) { iOneLogLength = (i + 1) + 1 - iStartIndex; byte[] bySSRAttLog = new byte[iOneLogLength]; Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength); udisk.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN2, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode); ListViewItem list = new ListViewItem(); list.Text = sPIN2; list.SubItems.Add(sTime_second); list.SubItems.Add(sDeviceID); list.SubItems.Add(sStatus); list.SubItems.Add(sVerified); list.SubItems.Add(sWorkcode); lvSSRAttLog.Items.Add(list); bySSRAttLog = null; iStartIndex += iOneLogLength; iOneLogLength = 0; } } stream.Close(); } }
//To read the attendence logs (For TFT screen devices,Filename:DeviceID_attolog.dat) private void btnSSRAttLogRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength;//length of the bytes to get from the data string sPIN2 = ""; string sVerified = ""; string sTime_second = ""; string sDeviceID = ""; string sStatus = ""; string sWorkcode = ""; openFileDialog1.Filter = "1_attlog(*.dat)|*.dat"; openFileDialog1.FileName = "1_attlog.dat";//1 stands for one possible deviceid if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); lvSSRAttLog.Items.Clear(); int iStartIndex = 0; int iOneLogLength;//the length of one line of attendence log for (int i = iStartIndex; i < iLength-2; i++)//modify by darcy on Dec.4 2009 { if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10) { iOneLogLength = (i + 1) + 1 - iStartIndex; byte[] bySSRAttLog = new byte[iOneLogLength]; Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength); udisk.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN2, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode); ListViewItem list = new ListViewItem(); list.Text = sPIN2; list.SubItems.Add(sTime_second); list.SubItems.Add(sDeviceID); list.SubItems.Add(sStatus); list.SubItems.Add(sVerified); list.SubItems.Add(sWorkcode); lvSSRAttLog.Items.Add(list); bySSRAttLog = null; iStartIndex += iOneLogLength; iOneLogLength = 0; } } stream.Close(); } }
//To read the extended attendence logs (Filename:DeviceID_attolog.dat) private void btnAttLogExtRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength;//length of the bytes to get from the data string sPIN = ""; string sVerified = ""; string sTime_second = ""; string sDeviceID = ""; string sStatus = ""; string sWorkcode = ""; openFileDialog1.Filter = "1_attlog(*.dat)|*.dat"; openFileDialog1.FileName = "1_attlog.dat";//1 stands for one possible deviceid if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); int iStart = 0;//the index of the last byte used to store the serial number(the value in this byte is Ascii code 10(the Escape character "\n")) int iEnd = 0;//the index of the last byte used to store the extended attendence logs(the value in this byte is Ascii code 10(the Escape character "\n")) int i = 0; for (i = 0; i < iLength; i++)//to get the value of iStart { if (byDataBuf[i] == 10) { iStart = i; break; ; } } for (i = iLength - 2; i >= 0; i--)//to get the value of iEnd { if (byDataBuf[i] == 10) { iEnd = i; break; } } byte[] bySNBuf = new byte[iStart + 1]; Array.Copy(byDataBuf, 0, bySNBuf, 0, iStart + 1); txtSN.Text = System.Text.Encoding.Default.GetString(bySNBuf); byte[] byCheckSumBuf = new byte[iLength - 1 - iEnd]; Array.Copy(byDataBuf, iEnd + 1, byCheckSumBuf, 0, iLength - 1 - iEnd); txtCheckSum.Text = System.Text.Encoding.Default.GetString(byCheckSumBuf); lvAttLog.Items.Clear(); int iStartIndex = iStart + 1; int iOneLogLength;//the length of one line of attendence log for (i = iStartIndex; i < iEnd+1; i++)//iEnd+1 means the bytes count of the data except the checksum { if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10) { iOneLogLength = (i + 1) + 1 - iStartIndex; byte[] bySSRAttLog = new byte[iOneLogLength]; Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength); udisk.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode); ListViewItem list = new ListViewItem(); list.Text = sPIN; list.SubItems.Add(sTime_second); list.SubItems.Add(sDeviceID); list.SubItems.Add(sStatus); list.SubItems.Add(sVerified); list.SubItems.Add(sWorkcode); lvAttLog.Items.Add(list); bySSRAttLog = null; iStartIndex += iOneLogLength; iOneLogLength = 0; } } stream.Close(); } }
//To read the extended attendence logs (Filename:DeviceID_attolog.dat) private void btnAttLogExtRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength;//length of the bytes to get from the data string sPIN = ""; string sVerified = ""; string sTime_second = ""; string sDeviceID = ""; string sStatus = ""; string sWorkcode = ""; openFileDialog1.Filter = "1_attlog(*.dat)|*.dat"; openFileDialog1.FileName = "1_attlog.dat";//1 stands for one possible deviceid if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); int iStart = 0; //the index of the last byte used to store the serial number(the value in this byte is Ascii code 10(the Escape character "\n")) int iEnd = 0; //the index of the last byte used to store the extended attendence logs(the value in this byte is Ascii code 10(the Escape character "\n")) int i = 0; for (i = 0; i < iLength; i++)//to get the value of iStart { if (byDataBuf[i] == 10) { iStart = i; break;; } } for (i = iLength - 2; i >= 0; i--)//to get the value of iEnd { if (byDataBuf[i] == 10) { iEnd = i; break; } } byte[] bySNBuf = new byte[iStart + 1]; Array.Copy(byDataBuf, 0, bySNBuf, 0, iStart + 1); txtSN.Text = System.Text.Encoding.Default.GetString(bySNBuf); byte[] byCheckSumBuf = new byte[iLength - 1 - iEnd]; Array.Copy(byDataBuf, iEnd + 1, byCheckSumBuf, 0, iLength - 1 - iEnd); txtCheckSum.Text = System.Text.Encoding.Default.GetString(byCheckSumBuf); lvAttLog.Items.Clear(); int iStartIndex = iStart + 1; int iOneLogLength; //the length of one line of attendence log for (i = iStartIndex; i < iEnd + 1; i++) //iEnd+1 means the bytes count of the data except the checksum { if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10) { iOneLogLength = (i + 1) + 1 - iStartIndex; byte[] bySSRAttLog = new byte[iOneLogLength]; Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength); udisk.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode); ListViewItem list = new ListViewItem(); list.Text = sPIN; list.SubItems.Add(sTime_second); list.SubItems.Add(sDeviceID); list.SubItems.Add(sStatus); list.SubItems.Add(sVerified); list.SubItems.Add(sWorkcode); lvAttLog.Items.Add(list); bySSRAttLog = null; iStartIndex += iOneLogLength; iOneLogLength = 0; } } stream.Close(); } }
private void btnAttLogExtRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength;//length of the bytes to get from the data string sPIN = ""; string sVerified = ""; string sTime_second = ""; string sDeviceID = ""; string sStatus = ""; string sWorkcode = ""; openFileDialog1.Filter = "1_attlog(*.dat)|*.dat"; openFileDialog1.FileName = "1_attlog.dat"; try { if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); int iStart = 0;//the index of the last byte used to store the serial number(the value in this byte is Ascii code 10(the Escape character "\n")) int iEnd = 0;//the index of the last byte used to store the extended attendence logs(the value in this byte is Ascii code 10(the Escape character "\n")) int i = 0; for (i = 0; i < iLength; i++)//to get the value of iStart { if (byDataBuf[i] == 10) { iStart = i; break; ; } } for (i = iLength - 2; i >= 0; i--)//to get the value of iEnd { if (byDataBuf[i] == 10) { iEnd = i; break; } } byte[] bySNBuf = new byte[iStart + 1]; Array.Copy(byDataBuf, 0, bySNBuf, 0, iStart + 1); byte[] byCheckSumBuf = new byte[iLength - 1 - iEnd]; Array.Copy(byDataBuf, iEnd + 1, byCheckSumBuf, 0, iLength - 1 - iEnd); lvAttLog.Items.Clear(); int iStartIndex = iStart + 1; int iOneLogLength;//the length of one line of attendence log for (i = iStartIndex; i < iEnd + 1; i++)//iEnd+1 means the bytes count of the data except the checksum { if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10) { iOneLogLength = (i + 1) + 1 - iStartIndex; byte[] bySSRAttLog = new byte[iOneLogLength]; Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength); udisk.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode); ListViewItem list = new ListViewItem() { Text = sPIN }; list.SubItems.Add(sTime_second); list.SubItems.Add(sDeviceID); list.SubItems.Add(sStatus); list.SubItems.Add(sVerified); list.SubItems.Add(sWorkcode); lvAttLog.Items.Add(list); bySSRAttLog = null; iStartIndex += iOneLogLength; iOneLogLength = 0; // save to database //Save to DataBase DBEngine.exec("sp_Checkinout_Save", "@UserID", sPIN, "@ChectTime", sTime_second, "@MachineNumber", sDeviceID, "@AttState", sStatus, "@VERIFYCODE", sVerified, "@WorkCode", sWorkcode); } } stream.Close(); } UIMessage.ShowMessage(CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { HPA.Common.Helper.ShowException(ex, this.Name, "btnUserRead_Click"); } }
private void btnSSRAttLogRead_Click(object sender, EventArgs e) { UDisk udisk = new UDisk(); byte[] byDataBuf = null; int iLength;//length of the bytes to get from the data string sPIN2 = ""; string sVerified = ""; string sTime_second = ""; string sDeviceID = ""; string sStatus = ""; string sWorkcode = ""; openFileDialog1.Filter = "1_attlog(*.dat)|*.dat"; openFileDialog1.FileName = "1_attlog.dat";//1 stands for one possible deviceid try { if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read); byDataBuf = File.ReadAllBytes(openFileDialog1.FileName); iLength = Convert.ToInt32(stream.Length); lvSSRAttLog.Items.Clear(); int iStartIndex = 0; int iOneLogLength;//the length of one line of attendence log for (int i = iStartIndex; i < iLength - 2; i++)//modify by darcy on Dec.4 2009 { if (byDataBuf[i] == 13 && byDataBuf[i + 1] == 10) { iOneLogLength = (i + 1) + 1 - iStartIndex; byte[] bySSRAttLog = new byte[iOneLogLength]; Array.Copy(byDataBuf, iStartIndex, bySSRAttLog, 0, iOneLogLength); udisk.GetAttLogFromDat(bySSRAttLog, iOneLogLength, out sPIN2, out sTime_second, out sDeviceID, out sStatus, out sVerified, out sWorkcode); ListViewItem list = new ListViewItem() { Text = sPIN2 }; list.SubItems.Add(sTime_second); list.SubItems.Add(sDeviceID); list.SubItems.Add(sStatus); list.SubItems.Add(sVerified); list.SubItems.Add(sWorkcode); lvSSRAttLog.Items.Add(list); //Save to DataBase DBEngine.exec("sp_Checkinout_Save", "@UserID", sPIN2, "@ChectTime", sTime_second, "@MachineNumber", sDeviceID, "@AttState", sStatus, "@VERIFYCODE", sVerified, "@WorkCode", sWorkcode); bySSRAttLog = null; iStartIndex += iOneLogLength; iOneLogLength = 0; } } stream.Close(); } UIMessage.ShowMessage(CommonConst.DATASAVED_SUCCESSFULLY, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { HPA.Common.Helper.ShowException(ex, this.Name, "btnUserRead_Click"); } }