Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
    protected void btnUploadUser_Click(object sender, EventArgs e)
    {
        DataTable dtuser      = new DataTable();
        DataTable dtFailedRec = new DataTable();

        if (Session["dtEmpUpload"] != null)
        {
            dtuser = (DataTable)Session["dtEmpUpload"];
        }
        if (lblSelectRecd.Text != "")
        {
            dtuser = new DataView(dtuser, "Emp_Code in (" + lblSelectRecd.Text.Substring(0, lblSelectRecd.Text.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable();
        }


        bool b = false;

        dtFailedRec = dtuser.Clone();
        bool IsDeviceSelected = false;

        foreach (GridViewRow gvdevicerow in gvDevice.Rows)
        {
            if (((CheckBox)gvdevicerow.FindControl("chkSelectDevice")).Checked)
            {
                DataTable dt = objDevice.GetDeviceMasterById(Session["CompId"].ToString(), gvDevice.DataKeys[gvdevicerow.RowIndex]["Device_Id"].ToString());

                string IP   = dt.Rows[0]["IP_Address"].ToString();
                int    port = Convert.ToInt32(dt.Rows[0]["Port"]);

                IsDeviceSelected = true;
                for (int i = 0; i < dtuser.Rows.Count; i++)
                {
                    b = false;
                    DataTable dtAllUser = new DataTable();

                    dtAllUser.Columns.Add("Name");
                    dtAllUser.Columns.Add("UserID");
                    dtAllUser.Columns.Add("Privilege");
                    dtAllUser.Columns.Add("Password");
                    dtAllUser.Columns.Add("CardNumber");
                    dtAllUser.Columns.Add("Enabled");

                    DataRow dr = dtAllUser.NewRow();
                    dr["Name"]      = dtuser.Rows[i]["Emp_Name"].ToString();
                    dr["UserID"]    = dtuser.Rows[i]["Emp_Code"].ToString();
                    dr["Privilege"] = dtuser.Rows[i]["Template1"].ToString();

                    dr["Password"] = dtuser.Rows[i]["Template2"].ToString();


                    dr["CardNumber"] = dtuser.Rows[i]["CardNo"].ToString();



                    dr["Enabled"] = dtuser.Rows[i]["sEnabled"].ToString();

                    dtAllUser.Rows.Add(dr);

                    try
                    {
                        //   b = objDeviceOp.UploadCardUser(dtAllUser, IP, port);
                    }
                    catch
                    {
                    }

                    DataTable dtFinger = new DataTable();

                    dtFinger.Columns.Add("sdwEnrollNumber");
                    dtFinger.Columns.Add("sName");
                    dtFinger.Columns.Add("idwFingerIndex");
                    dtFinger.Columns.Add("sTmpData");
                    dtFinger.Columns.Add("iPrivilege");

                    dtFinger.Columns.Add("sPassword");
                    dtFinger.Columns.Add("sEnabled");

                    dtFinger.Columns.Add("iFlag");

                    DataRow dr1 = dtFinger.NewRow();

                    dr1["sdwEnrollNumber"] = dtuser.Rows[i]["Emp_Code"].ToString();
                    dr1["sName"]           = dtuser.Rows[i]["Emp_Name"].ToString();
                    dr1["idwFingerIndex"]  = dtuser.Rows[i]["idwFingerIndex"].ToString();
                    dr1["sPassword"]       = dtuser.Rows[i]["Template2"].ToString();



                    dr1["iPrivilege"] = dtuser.Rows[i]["Template1"].ToString();
                    dr1["sTmpData"]   = dtuser.Rows[i]["Template3"].ToString();

                    dr1["sEnabled"] = dtuser.Rows[i]["sEnabled"].ToString();

                    dr1["iFlag"] = dtuser.Rows[i]["iFlag"].ToString();
                    dtFinger.Rows.Add(dr1);

                    try
                    {
                        if (dtuser.Rows[i]["Template3"].ToString() != "")
                        {
                            if (chkUploadFP.Checked)
                            {
                                b = false;
                                b = objDeviceOp.UploadUser(dtFinger, IP, port);
                            }
                        }
                    }
                    catch
                    {
                    }


                    DataTable dtFace = new DataTable();
                    dtFace.Columns.Add("sUserID");
                    dtFace.Columns.Add("sName");
                    dtFace.Columns.Add("sPassword");
                    dtFace.Columns.Add("iPrivilege");
                    dtFace.Columns.Add("iFaceIndex");
                    dtFace.Columns.Add("sTmpData");
                    dtFace.Columns.Add("iLength");
                    dtFace.Columns.Add("bEnabled");



                    DataRow dr2 = dtFace.NewRow();
                    dr2["sUserID"] = dtuser.Rows[i]["Emp_Code"].ToString();
                    dr2["sName"]   = dtuser.Rows[i]["Emp_Name"].ToString();

                    dr2["sPassword"]  = dtuser.Rows[i]["Template2"].ToString();
                    dr2["iPrivilege"] = dtuser.Rows[i]["Template1"].ToString();
                    dr2["iFaceIndex"] = dtuser.Rows[i]["Template5"].ToString();
                    dr2["sTmpData"]   = dtuser.Rows[i]["Template4"].ToString();
                    dr2["iLength"]    = dtuser.Rows[i]["Template8"].ToString();
                    dr2["bEnabled"]   = dtuser.Rows[i]["sEnabled"].ToString();


                    dtFace.Rows.Add(dr2);
                    try
                    {
                        if (chkUploadFace.Checked)
                        {
                            b = false;
                            b = objDeviceOp.UploadUserFace(IP, port, dtFace);
                        }
                    }
                    catch
                    {
                    }


                    if (b == false)
                    {
                        dtFailedRec.ImportRow(dtuser.Rows[i]);
                    }
                }
            }
        }


        if (!IsDeviceSelected)
        {
            DisplayMessage("Please Select Device");
        }
        else
        {
            if (dtFailedRec.Rows.Count > 0)
            {
                pnlFailedRec.Visible      = true;
                gvFailedRecord.DataSource = dtFailedRec;
                gvFailedRecord.DataBind();
                lblFailedRec.Text = "Failed Records :" + dtFailedRec.Rows.Count.ToString();
            }
            else
            {
                pnlDestDevice.Visible = false;
                pnlFailedRec.Visible  = false;
                pnlList.Visible       = true;
            }
            DisplayMessage("User Uploaded");
        }
    }