示例#1
0
 public string GetData(DatData id)
 {
     foreach (GameMetaData gameMD in _gameMetaData)
     {
         if (id == gameMD.Id) return gameMD.Value;
         if (id < gameMD.Id) return "";
     }
     return "";
 }
示例#2
0
        public void AddData(DatData id, string val)
        {
            if (string.IsNullOrEmpty(val))
                return;

            int pos = 0;
            while (pos < _gameMetaData.Count && _gameMetaData[pos].Id < id)
                pos++;

            _gameMetaData.Insert(pos, new GameMetaData(id, val));
        }
示例#3
0
 public string GetData(DatData id)
 {
     foreach (DatMetaData gameMD in _gameMetaData)
     {
         if (id == gameMD.Id)
         {
             return(gameMD.Value);
         }
         if (id < gameMD.Id)
         {
             return("");
         }
     }
     return("");
 }
示例#4
0
        public void AddData(DatData id, string val)
        {
            if (string.IsNullOrWhiteSpace(val))
            {
                return;
            }

            int pos = 0;

            while (pos < _gameMetaData.Count && _gameMetaData[pos].Id < id)
            {
                pos++;
            }

            _gameMetaData.Insert(pos, new DatMetaData(id, val));
        }
示例#5
0
        public void AddData(DatData id, string val)
        {
            if (string.IsNullOrEmpty(val))
            {
                return;
            }

            int pos = 0;

            while ((pos < _gameMetaData.Count) && (_gameMetaData[pos].Id < id))
            {
                pos++;
            }

            _gameMetaData.Insert(pos, new GameMetaData(id, val));
        }
示例#6
0
        public override void Read(Stream s)
        {
            _root = new DatData();

            _root.ItemCount = s.ReadValueS32(Endianness);

            s.ReadValueS32(Endianness);

            var stringBase = 8 + _root.ItemCount * 32;

            for (var i = 0; i < _root.ItemCount; i++)
            {
                var item = new ItemData
                {
                    Offset = stringBase + s.ReadValueS32(Endianness),
                    Flags  = s.ReadBytes(28)
                };

                _root.Data.Add(item);
            }

            for (var i = 0; i < _root.ItemCount - 1; i++)
            {
                _root.Data[i].Size = _root.Data[i + 1].Offset - _root.Data[i].Offset;
            }

            _root.Data[_root.ItemCount - 1].Size = (int)(s.Length - _root.Data[_root.ItemCount - 1].Offset);

            for (var i = 0; i < _root.ItemCount; i++)
            {
                var item = _root.Data[i];
                s.Seek(item.Offset, SeekOrigin.Begin);
                item.BinaryContent = s.ReadBytes(item.Size);

                ExtractStrings(item);
            }
        }
示例#7
0
 public DatMetaData(DatData id, string value)
 {
     Id    = id;
     Value = value;
 }
示例#8
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            //if ((_oInput == InputOption.LAN) && (_bioType == BioType.ZK))
            //{

            //}
            //else if ((_oInput == InputOption.USB) && (_bioType == BioType.ZK))
            //{
            machineInstanceBindingSource.AddNew();
            var 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);

                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);

                        var dat = new DatData
                        {
                            Pin      = sPIN2,
                            AttTime  = sTime_second,
                            Status   = sStatus,
                            Verify   = sVerified,
                            Device   = sDeviceID,
                            WorkCode = sWorkcode
                        };

                        _listDat.Add(dat);

                        bySSRAttLog   = null;
                        iStartIndex  += iOneLogLength;
                        iOneLogLength = 0;
                    }
                }
                stream.Close();
            }
            datDataBindingSource.DataSource = null;
            datDataBindingSource.DataSource = _listDat;

            //}
            //else if ((_oInput == InputOption.USB) && (_bioType == BioType.Realand))
            //{

            //}
            //else
            //{
            //    return;
            //}
        }
示例#9
0
 public GameMetaData(DatData id, String value)
 {
     Id    = id;
     Value = value;
 }
示例#10
0
 public GameMetaData(DatData id, String value)
 {
     Id = id;
     Value = value;
 }
示例#11
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            machineInstanceBindingSource.AddNew();
            if ((radioButton2.Checked) && (radioButton3.Checked))
            {
                var 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    = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    openFileDialog1.Filter = @"zklog(*.dat)|*.dat";
                    FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Read);
                    byDataBuf = File.ReadAllBytes(openFileDialog1.FileName);
                    iLength   = Convert.ToInt32(stream.Length);

                    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);

                            var dat = new DatData
                            {
                                Pin      = sPIN2,
                                AttTime  = sTime_second,
                                Status   = sStatus,
                                Verify   = sVerified,
                                Device   = sDeviceID,
                                WorkCode = sWorkcode
                            };

                            _listDat.Add(dat);

                            bySSRAttLog   = null;
                            iStartIndex  += iOneLogLength;
                            iOneLogLength = 0;
                        }
                    }
                    stream.Close();
                }
                datDataBindingSource.DataSource = null;
                datDataBindingSource.DataSource = _listDat;
                _option = 1;
            }
            else if ((radioButton2.Checked) && (radioButton4.Checked))
            {
                openFileDialog1.Filter = @"HisGLog_0001_20170801(*.csv)|*.csv";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    var filename = openFileDialog1.FileName;
                    Console.WriteLine(filename);
                    string[] allLines = File.ReadAllLines(openFileDialog1.FileName);
                    var      query    = from line in allLines
                                        let data = line.Split('\t')
                                                   select new DatData
                    {
                        Pin      = data[2],
                        AttTime  = data[8],
                        Device   = data[1],
                        Status   = data[4],
                        Verify   = data[5],
                        WorkCode = data[7]
                    };

                    foreach (var item in query)
                    {
                        int iResult = 0;
                        if (int.TryParse(item.Pin, out iResult))
                        {
                            _listDat.Add(item);
                        }
                    }
                }
                datDataBindingSource.DataSource = _listDat;
                _option = 2;
            }
            else if ((radioButton2.Checked) && (radioButtonAnviz.Checked))
            {
                try
                {
                    System.Diagnostics.Process.Start(Directory.GetCurrentDirectory() + @"\x.bat", Directory.GetCurrentDirectory() + @"\anviz\anviz_file\convert.js");

                    //command process - call to cmd and execute node.js
                    //var startInfo = new ProcessStartInfo
                    //{
                    //    FileName = "cmd.exe",
                    //    RedirectStandardInput = true,
                    //    RedirectStandardOutput = true,
                    //    UseShellExecute = false,
                    //    CreateNoWindow = false
                    //};
                    //var process = new Process { StartInfo = startInfo };
                    //process.Start();
                    //var filePath = Directory.GetCurrentDirectory() + @"\anviz\anviz_file\convert.js";
                    //process.StandardInput.WriteLine(@"node " + filePath);
                    //process.StandardInput.WriteLine("exit");
                    //process.WaitForExit();

                    //setting file and display the result
                    var filename = Directory.GetCurrentDirectory() + @"\anviz\anviz_file\bak.xlsx";
                    Console.WriteLine(filename);
                    app = new Excel.Application {
                        Visible = false
                    };
                    book  = app.Workbooks.Open(filename);
                    sheet = (Excel.Worksheet)book.Sheets[1];
                    var lastRow  = sheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row;
                    var tempList = new List <DatData>();
                    for (var i = 2; i < lastRow; i++)
                    {
                        var values = (System.Array)sheet.get_Range("A" + i.ToString(), "D" + i.ToString()).Cells.Value;
                        tempList.Add(new DatData
                        {
                            Pin      = values.GetValue(1, 1).ToString(),
                            AttTime  = values.GetValue(1, 2).ToString(),
                            Status   = values.GetValue(1, 3).ToString(),
                            Device   = "0",
                            Verify   = "0",
                            WorkCode = "0"
                        });
                    }
                    book.Close(Type.Missing, Type.Missing, Type.Missing);
                    app.Quit();
                    foreach (var item in tempList)
                    {
                        int iResult = 0;
                        if (int.TryParse(item.Pin, out iResult))
                        {
                            _listDat.Add(item);
                        }
                    }
                    datDataBindingSource.DataSource = _listDat;
                    _option = 2;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"Kindly check the error: " + ex.Message);
                }
            }
            else if ((radioButton2.Checked) && (radioButtonW.Checked))
            {
                openFileDialog1.Filter = @"GLog_001(*.txt)|*.txt";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    var filename = openFileDialog1.FileName;
                    Console.WriteLine(filename);
                    string[] allLines = File.ReadAllLines(openFileDialog1.FileName);
                    var      query    = from line in allLines
                                        let data = line.Split('\t')
                                                   select new DatData
                    {
                        Pin      = data[2],
                        AttTime  = data[6],
                        Device   = data[1],
                        Status   = data[4],
                        Verify   = data[5],
                        WorkCode = data[5]
                    };

                    foreach (var item in query)
                    {
                        int iResult = 0;
                        if (int.TryParse(item.Pin, out iResult))
                        {
                            _listDat.Add(item);
                        }
                    }
                }
                datDataBindingSource.DataSource = _listDat;
                _option = 2;
            }
            else if ((radioButton1.Checked) && (radioButton3.Checked))
            {
                int connectError = 0;
            }
        }