Example #1
0
        //To write the attendence logs (For TFT,Filename:DeviceID_attolog.dat)
        private void btnSSRAttLogWrite_Click(object sender, EventArgs e)
        {
            UDisk udisk = new UDisk();

            int iCount = lvSSRAttLog.Items.Count;
            int iLength = 0;
            byte[] byTemporaryBuf = new byte[1024 * 1024 * 40];

            saveFileDialog1.Filter = "1_attlog(*.dat)|*.dat";
            saveFileDialog1.FileName = "1_attlog.dat";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                int iTemBufIndex = 0;
                for (int i = 0; i < iCount; i++)
                {
                    string sPIN2 = lvSSRAttLog.Items[i].SubItems[0].Text;//don't default he space,otherwise the data will be wrong
                    string sTime_second = lvSSRAttLog.Items[i].SubItems[1].Text;
                    string sDeviceID = lvSSRAttLog.Items[i].SubItems[2].Text;
                    string sStatus = lvSSRAttLog.Items[i].SubItems[3].Text;
                    string sVerified = lvSSRAttLog.Items[i].SubItems[4].Text;
                    string sWorkcode = lvSSRAttLog.Items[i].SubItems[5].Text;
                    byte[] bySSRAttInfo = null;

                    int iOneLogLength = 0;
                    udisk.SetAttLogToDat(out bySSRAttInfo, out iOneLogLength, sPIN2, sTime_second, sDeviceID, sStatus, sVerified, sWorkcode);
                    Array.Copy(bySSRAttInfo, 0, byTemporaryBuf, iTemBufIndex, iOneLogLength);
                    iTemBufIndex += iOneLogLength;
                    iLength += iOneLogLength;
                }
            }
            byte[] byDataBuf = new byte[iLength];
            Array.Copy(byTemporaryBuf, byDataBuf, iLength);
            File.WriteAllBytes(saveFileDialog1.FileName, byDataBuf);
        }
Example #2
0
        //To write the extended attendence logs (Filename:DeviceID_attolog.dat)
        private void btnAttLogExtWrite_Click(object sender, EventArgs e)
        {
            UDisk udisk = new UDisk();

            int iCount = lvAttLog.Items.Count;
            int iLength = 0;
            byte[] byTemporaryBuf = new byte[1024 * 1024 * 40];

            string sSN = txtSN.Text.Trim() + "\r\n";
            byte[] bySN = new byte[sSN.Length];
            bySN = System.Text.Encoding.Default.GetBytes(sSN);

            string sCheckSum = txtCheckSum.Text.Trim() + "\r\n";
            byte[] byCheckSum = new byte[sCheckSum.Length];
            byCheckSum = System.Text.Encoding.Default.GetBytes(sCheckSum);

            saveFileDialog1.Filter = "1_attlog(*.dat)|*.dat";
            saveFileDialog1.FileName = "1_attlog.dat";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                int iTemBufIndex = 0;
                for (int i = 0; i < iCount; i++)
                {
                    string sPIN2 = lvAttLog.Items[i].SubItems[0].Text;//don't default he space,otherwise the data will be wrong
                    string sTime_second = lvAttLog.Items[i].SubItems[1].Text;
                    string sDeviceID = lvAttLog.Items[i].SubItems[2].Text;
                    string sStatus = lvAttLog.Items[i].SubItems[3].Text;
                    string sVerified = lvAttLog.Items[i].SubItems[4].Text;
                    string sWorkcode = lvAttLog.Items[i].SubItems[5].Text;
                    byte[] byAttInfo = null;

                    int iOneLogLength = 0;
                    udisk.SetAttLogToDat(out byAttInfo, out iOneLogLength, sPIN2, sTime_second, sDeviceID, sStatus, sVerified, sWorkcode);
                    Array.Copy(byAttInfo, 0, byTemporaryBuf, iTemBufIndex, iOneLogLength);
                    iTemBufIndex += iOneLogLength;
                    iLength += iOneLogLength;
                }
            }
            byte[] byDataBuf = new byte[sSN.Length+sCheckSum.Length+iLength];
            Array.Copy(bySN, byDataBuf, sSN.Length);
            Array.Copy(byTemporaryBuf, 0, byDataBuf, sSN.Length, iLength);
            Array.Copy(byCheckSum, 0, byDataBuf, sSN.Length + iLength,sCheckSum.Length);

            File.WriteAllBytes(saveFileDialog1.FileName, byDataBuf);
        }