Ejemplo n.º 1
0
        public ActionResult ConnectBiometric(DownloadDataViewModel model)
        {
            device                 = new Device();
            device.DN              = 1;
            device.Model           = "A-C071";
            device.ConnectionModel = 5;

            device.IpAddress         = model.IpAddress;
            device.IpPort            = int.Parse(model.Port);
            device.CommunicationType = CommunicationType.Tcp;
            deviceConnection         = DeviceConnection.CreateConnection(ref device);
            System.Diagnostics.Debug.WriteLine(deviceConnection.Open());

            if (deviceConnection.Open() > 0)
            {
                deviceEty                  = new DeviceComEty();
                deviceEty.Device           = device;
                deviceEty.DeviceConnection = deviceConnection;
            }
            else
            {
            }


            return(View());
        }
Ejemplo n.º 2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                device                 = new Device();
                device.DN              = 1;
                device.Password        = "******";
                device.Model           = "A-C030";
                device.ConnectionModel = 5;//等于5时才能正确加载ZD2911通讯模块

                if (rdb_Network.Checked == true)
                {
                    //ip address
                    if (string.IsNullOrEmpty(txt_IP.Text.Trim()))
                    {
                        MessageBox.Show("Please Input IP Address", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txt_IP.Focus();
                        return;
                    }

                    if (false == ConvertObject.IsCorrenctIP(txt_IP.Text.Trim()))
                    {
                        MessageBox.Show("Illegal IP Address", "Prompt", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txt_IP.Focus();
                        return;
                    }

                    device.IpAddress         = txt_IP.Text.Trim();
                    device.IpPort            = int.Parse(txt_Port.Text);
                    device.CommunicationType = CommunicationType.Tcp;
                }
                else
                {
                    device.CommunicationType = CommunicationType.Usb;
                }

                deviceConnection = DeviceConnection.CreateConnection(ref device);
                if (deviceConnection.Open() > 0)
                {
                    deviceEty                  = new DeviceComEty();
                    deviceEty.Device           = device;
                    deviceEty.DeviceConnection = deviceConnection;
                    MessageBox.Show("Device successfully connected", "System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnBiometricData.Enabled = true;
                    btnDisconnect.Enabled    = true;
                    btnConnect.Enabled       = false;
                }
                else
                {
                    MessageBox.Show("Failed to Connect to Device", "System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        public ActionResult ConnectBiometric(ConnectViewModel model) //this is one page bale localhost:portnum/DownloadData/ConnectBiometric << pwde kani localhost:portnum/DownloadData/Index
        {
            bool x = false;

            try
            {
                device                 = new Device();
                device.DN              = 1;
                device.Model           = "A-C030";
                device.ConnectionModel = 5;

                device.IpAddress         = model.IpAddress;
                device.IpPort            = int.Parse(model.Port);
                device.CommunicationType = CommunicationType.Tcp;
                deviceConnection         = DeviceConnection.CreateConnection(ref device);
                System.Diagnostics.Debug.WriteLine(deviceConnection.Open());

                if (deviceConnection.Open() > 0)
                {
                    deviceEty                  = new DeviceComEty();
                    deviceEty.Device           = device;
                    deviceEty.DeviceConnection = deviceConnection;
                    x = true;
                }
                else
                {
                    TempData["msg"] = "<script>alert('Connection Failed');</script>";
                    x = false;
                }
            }
            catch (Exception ex)
            {
                TempData["msg"] = "<script>alert('ex');</script>";
            }

            if (x == true)
            {
                return(View());
            }
            else
            {
                return(View("Index"));
            }
        }
Ejemplo n.º 4
0
 public frmLogData(DeviceComEty deviceEty)
 {
     InitializeComponent();
     device           = deviceEty.Device;
     deviceConnection = deviceEty.DeviceConnection;
 }
Ejemplo n.º 5
0
        public ActionResult DownloadDataBiometric()
        {
            //List<DownloadDataViewModel> list = new List<DownloadDataViewModel>();

            //------------------------------------------ BINUGO CODE
            device                 = new Device();
            device.DN              = 1;
            device.Model           = "A-C030";
            device.ConnectionModel = 5;

            device.IpAddress         = "192.168.005.001";
            device.IpPort            = 123;
            device.CommunicationType = CommunicationType.Tcp;
            deviceConnection         = DeviceConnection.CreateConnection(ref device);
            System.Diagnostics.Debug.WriteLine(deviceConnection.Open());
            deviceEty                  = new DeviceComEty();
            deviceEty.Device           = device;
            deviceEty.DeviceConnection = deviceConnection;
            //-----------------------------------------

            object extraProperty = new object();
            object extraData     = new object();

            extraData = Global.DeviceBusy;
            try
            {
                List <DateTime> dtList = new List <DateTime>();
                bool            result = deviceConnection.SetProperty(DeviceProperty.Enable, extraProperty, device, extraData);

                //------------------------------------------ BINUGO CODE
                dtList.Add(Convert.ToDateTime("08/01/2017"));
                dtList.Add(DateTime.Now);
                //-----------------------------------------

                //dtList.Add(model.TO.Date);
                //dtList.Add(model.TO.Date);
                extraProperty = false;
                extraData     = dtList;
                result        = deviceConnection.GetProperty(DeviceProperty.AttRecordsCount, extraProperty, ref device,
                                                             ref extraData);
                if (false == result)
                {
                    TempData["msg"] = "<script>alert('Download Failed');</script>";
                }

                int recordCount = (int)extraData;

                if (0 == recordCount)
                {//为0时说明没有新日志记录
                    ListDownloadData.Clear();
                }

                List <bool> boolList = new List <bool>();

                //----------------------------------------- BINUGO CODE
                boolList.Add(false); //所有日志
                boolList.Add(false); //清除新日志标记,false则不清除
                //-----------------------------------------
                extraProperty = boolList;
                extraData     = dtList;
                result        = deviceConnection.GetProperty(DeviceProperty.AttRecords, extraProperty, ref device, ref extraData);
                if (result)
                {
                    int           i          = 1;
                    int           y          = 0;
                    List <Record> recordList = (List <Record>)extraData;
                    ListDownloadData.Clear();
                    foreach (Record record in recordList)
                    {
                        ListDownloadData.Add(new DownloadDataViewModel {
                            SN    = i.ToString(),
                            DN    = record.DN.ToString(),
                            DIN   = record.DIN.ToString(),
                            Type  = ConvertObject.GLogType(record.Verify),
                            mode  = ConvertObject.IOMode(record.Action),
                            Clock = record.Clock.ToString("yyyy-MM-dd HH:mm:ss")
                        });
                        i++;
                    }
                    Session["SessionName"] = ListDownloadData;
                }
                else
                {
                    TempData["msg"] = "<script>alert('Download Failed');</script>";
                }
            }
            catch (Exception)
            {
                TempData["msg"] = "<script>alert('Download Failed');</script>";
            }


            return(View("ConnectBiometric", ListDownloadData));
        }