示例#1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Device_Operation_Lan obj = new Device_Operation_Lan();
        DataTable            dt  = new DataTable();

        dt = obj.GetUserFace("192.168.5.186", 4370);
        obj.InitializeDevice("192.168.5.186", 4370);
        obj.UploadUserFace("192.168.5.186", 4370, dt);
    }
示例#2
0
    protected void btnSaveSelected_Click(object sender, EventArgs e)
    {
        string    optype = "1";
        DataTable dtUser = new DataTable();

        dtUser.Columns.Add("sdwEnrollNumber");
        dtUser.Columns.Add("sName");
        dtUser.Columns.Add("sPassWord");
        dtUser.Columns.Add("iPrivilege");
        dtUser.Columns.Add("sTmpData");
        dtUser.Columns.Add("sCardNumber");
        dtUser.Columns.Add("Emp_Id");
        dtUser.Columns.Add("IP");
        dtUser.Columns.Add("Port");
        dtUser.Columns.Add("Device_Id");
        dtUser.Columns.Add("sEnabled");

        if (chkFinger.Checked && chkFace.Checked)
        {
            optype = "4";
        }

        else if (chkFace.Checked)
        {
            optype = "3";
        }
        else if (chkFinger.Checked)
        {
            optype = "2";
        }


        for (int rowcount = 0; rowcount < gvUser.Rows.Count; rowcount++)
        {
            if (((CheckBox)gvUser.Rows[rowcount].FindControl("chkSel")).Checked)
            {
                string EnrollNo = gvUser.DataKeys[rowcount]["sdwEnrollNumber"].ToString();

                string Password       = gvUser.DataKeys[rowcount]["sPassword"].ToString();
                string EmpId          = gvUser.DataKeys[rowcount]["Emp_Id"].ToString();
                string empname        = gvUser.DataKeys[rowcount]["sName"].ToString();
                string Privilege      = gvUser.DataKeys[rowcount]["iPrivilege"].ToString();
                string FingerTemplate = string.Empty;
                string DeviceId       = gvUser.DataKeys[rowcount]["Device_Id"].ToString();
                string ip             = gvUser.DataKeys[rowcount]["IP"].ToString();
                string Port           = gvUser.DataKeys[rowcount]["Port"].ToString();

                string iflag    = string.Empty;
                string senabled = gvUser.DataKeys[rowcount]["bEnabled"].ToString();
                string CardNo   = gvUser.DataKeys[rowcount]["sCardNumber"].ToString();

                DataRow dr = dtUser.NewRow();
                dr["sdwEnrollNumber"] = EnrollNo;
                dr["sName"]           = empname;
                dr["sPassword"]       = Password;
                dr["iPrivilege"]      = Privilege;
                dr["sEnabled"]        = senabled;
                dr["sCardNumber"]     = CardNo;
                dr["Emp_Id"]          = EmpId;
                dr["Device_Id"]       = DeviceId;
                dr["IP"]       = ip;
                dr["Port"]     = Port;
                dr["sEnabled"] = senabled;
                dtUser.Rows.Add(dr);
            }
        }



        DataTable dtFinger = new DataTable();
        DataTable dtFace   = new DataTable();

        DataTable dtDistinctDevice = dtUser.DefaultView.ToTable(true, "Device_Id");

        for (int devicecounter = 0; devicecounter < dtDistinctDevice.Rows.Count; devicecounter++)
        {
            DataTable dtUserByDevice = new DataView(dtUser, "Device_Id='" + dtDistinctDevice.Rows[devicecounter][0].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable();
            if (dtUserByDevice.Rows.Count > 0)
            {
                string ip   = dtUserByDevice.Rows[0]["IP"].ToString();
                string Port = dtUserByDevice.Rows[0]["Port"].ToString();
                bool   IsDeviceConnected = false;
                if (objDeviceOp.Device_Connection(ip, Convert.ToInt32(Port), 0))
                {
                    IsDeviceConnected = true;
                }
                for (int rowcount = 0; rowcount < dtUserByDevice.Rows.Count; rowcount++)
                {
                    objEmp = new EmployeeMaster();
                    if (rowcount % 50 == 0)
                    {
                        ;
                    }

                    string EnrollNo      = dtUserByDevice.Rows[rowcount]["sdwEnrollNumber"].ToString();
                    string DeviceEmpName = dtUserByDevice.Rows[rowcount]["sName"].ToString();
                    string Password      = dtUserByDevice.Rows[rowcount]["sPassword"].ToString();
                    string EmpId         = dtUserByDevice.Rows[rowcount]["Emp_Id"].ToString();

                    string Privilege      = dtUserByDevice.Rows[rowcount]["iPrivilege"].ToString();
                    string DeviceId       = dtUserByDevice.Rows[rowcount]["Device_Id"].ToString();
                    string senabled       = dtUserByDevice.Rows[rowcount]["sEnabled"].ToString();
                    string CardNo         = dtUserByDevice.Rows[rowcount]["sCardNumber"].ToString();
                    string FingerTemplate = string.Empty;
                    string iflag          = string.Empty;
                    string faceindex      = string.Empty;
                    string facedata       = string.Empty;
                    string facelength     = string.Empty;
                    string fingerindex    = string.Empty;
                    if (EmpId.Trim() != "")
                    {
                        DataTable dtEmpD = objEmp.GetEmployeeMaster(Session["CompId"].ToString());
                        dtEmpD = new DataView(dtEmpD, "Emp_Code='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable();

                        if (dtEmpD.Rows.Count == 0)
                        {
                            int b = 0;
                            b = objEmp.InsertEmployeeMaster(Session["CompId"].ToString(), DeviceEmpName, DeviceEmpName, EmpId, "", Session["BrandId"].ToString(), Session["LocId"].ToString(), "1", "1", "1", "1", "1", "1", DateTime.Now.ToString(), DateTime.Now.ToString(), "On Role", DateTime.Now.ToString(), "Male", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), "", "");


                            objEmpParam.InsertEmployeeParameterOnEmployeeInsert(Session["CompId"].ToString(), b.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
                        }
                    }
                    if (IsDeviceConnected)
                    {
                        if (optype == "2")
                        {
                            DataTable dtFingertemp = objDeviceOp.GetUserFinger(ip, Convert.ToInt32(Port));
                            if (dtFingertemp.Rows.Count > 0)
                            {
                                dtFingertemp = new DataView(dtFingertemp, "sdwEnrollNumber='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable();
                                try
                                {
                                    FingerTemplate = dtFingertemp.Rows[0]["sTmpData"].ToString();
                                    iflag          = dtFingertemp.Rows[0]["iFlag"].ToString();
                                    fingerindex    = dtFingertemp.Rows[0]["idwFingerIndex"].ToString();
                                    senabled       = dtFingertemp.Rows[0]["sEnabled"].ToString();
                                }
                                catch
                                {
                                }
                                objEmpInfo.UpdateAccessControlFingerInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString());
                            }
                        }
                        else if (optype == "3")
                        {
                            DataTable dtFaceTemp = objDeviceOp.GetUserFace(ip, Convert.ToInt32(Port));

                            if (dtFaceTemp.Rows.Count > 0)
                            {
                                dtFaceTemp = new DataView(dtFaceTemp, "sUSERID='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable();

                                try
                                {
                                    faceindex  = dtFaceTemp.Rows[0]["iFaceIndex"].ToString();
                                    facedata   = dtFaceTemp.Rows[0]["sTmpData"].ToString();
                                    facelength = dtFaceTemp.Rows[0]["iLength"].ToString();
                                    senabled   = dtFaceTemp.Rows[0]["bEnabled"].ToString();
                                }
                                catch
                                {
                                }
                                objEmpInfo.UpdateAccessControlFaceInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString());
                            }
                        }
                        else if (optype == "4")
                        {
                            DataTable dtFingertemp = objDeviceOp.GetUserFinger(ip, Convert.ToInt32(Port));
                            if (dtFingertemp.Rows.Count > 0)
                            {
                                dtFingertemp = new DataView(dtFingertemp, "sdwEnrollNumber='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable();
                                try
                                {
                                    FingerTemplate = dtFingertemp.Rows[0]["sTmpData"].ToString();
                                    iflag          = dtFingertemp.Rows[0]["iFlag"].ToString();
                                    fingerindex    = dtFingertemp.Rows[0]["idwFingerIndex"].ToString();
                                    senabled       = dtFingertemp.Rows[0]["sEnabled"].ToString();
                                }
                                catch
                                {
                                }
                                objEmpInfo.UpdateAccessControlFingerInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString());
                            }

                            DataTable dtFaceTemp = objDeviceOp.GetUserFace(ip, Convert.ToInt32(Port));

                            if (dtFaceTemp.Rows.Count > 0)
                            {
                                dtFaceTemp = new DataView(dtFaceTemp, "sUSERID='" + EmpId + "'", "", DataViewRowState.CurrentRows).ToTable();
                                try
                                {
                                    faceindex  = dtFaceTemp.Rows[0]["iFaceIndex"].ToString();
                                    facedata   = dtFaceTemp.Rows[0]["sTmpData"].ToString();
                                    facelength = dtFaceTemp.Rows[0]["iLength"].ToString();
                                    senabled   = dtFingertemp.Rows[0]["bEnabled"].ToString();
                                }
                                catch
                                {
                                }
                                objEmpInfo.UpdateAccessControlFaceInfo(GetEmpId(EmpId), CardNo, Password, Privilege, FingerTemplate, facedata, faceindex, facelength, fingerindex, iflag, senabled, false.ToString(), false.ToString());
                            }
                        }
                    }
                }
            }
        }


        DisplayMessage("Users Saved");
    }