Пример #1
0
        private void GetUserIDListFromMac()
        {
            bool   state;
            bool   ret               = false;
            int    vnResultCode      = -1;
            UInt32 vEnrollNumber     = 0;
            int    vBackupNumber     = 0;
            int    vPrivilege        = 0;
            int    vnEnableFlag      = 0;
            string UserName          = "";
            int    EnrollNumberCount = 0;
            int    PersonNum         = 0;

            lblMsg.ForeColor = Color.FromName("Black");
            TDIConnInfo conn;

            progBar1.ProgressType = DevComponents.DotNetBar.eProgressItemType.Marquee;
            progBar1.Visible      = true;
            lblMsg1.Visible       = true;
            btnStop.Visible       = true;
            btnStop.Focus();
            if (connList.Count > 0)
            {
                for (int i = 0; i < connList.Count; i++)
                {
                    conn = connList[i];

                    switch (conn.MacSeriesTypeId)
                    {
                    case 2:
                        if (SystemInfo.ShowSEA != 1)
                        {
                            Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "MsgUnModuleInfo", ""), Pub.GetResText(formCode, "SeaDev", "")));
                            break;
                        }
                        if (RegisterInfo.IsValid || RegisterInfo.IsTest)
                        {
                            if (RegisterInfo.EndDate < DateTime.Now)
                            {
                                Pub.MessageBoxShow(RegisterInfo.StateText);
                                break;
                            }
                        }
                        SystemInfo.MacSeriesTypeId = 2;
                        string url = "http://" + conn.NetHost + "/";
                        //查询人员总数
                        string                       searchTotlePersonUrl      = url + "action/SearchPersonNum";
                        SearchTotlePerson            searchTotlePerson         = new SearchTotlePerson(Convert.ToInt32(conn.MacSN), 0, "", "", 2, "0-100", 0, "");
                        jsonBody <SearchTotlePerson> jsonBodySearchTotlePerson = new jsonBody <SearchTotlePerson>("SearchPersonNum", searchTotlePerson);
                        string                       jsonString = JsonConvert.SerializeObject(jsonBodySearchTotlePerson);
                        ret = DeviceObject.objFK623.POST_GetResponse(searchTotlePersonUrl, conn.MacSeriesUserName, conn.SeaSeries_Pwd, ref jsonString);
                        if (!ret)
                        {
                            lblMsg.ForeColor = Color.FromName("red");
                            lblMsg.Text      = DeviceObject.objFK623.SeaBodyStr();
                            continue;
                        }
                        jsonBody <SearchTotlePersonInfo> searchTotlePersonInfo = JsonConvert.DeserializeObject <jsonBody <SearchTotlePersonInfo> >(jsonString);
                        {
                            PersonNum = searchTotlePersonInfo.info.PersonNum;
                        }
                        if (PersonNum == 0)
                        {
                            lblMsg.ForeColor = Color.FromName("red");
                            lblMsg.Text      = (Pub.GetResText(formCode, "ErrorUnUserID", ""));
                            continue;
                        }
                        int count = 0;
                        while (true)
                        {
                            if (Stop || StopGet)
                            {
                                break;
                            }
                            //查询人员
                            string searchMultipleUrl            = url + "action/SearchPersonList";
                            SearchMultiplePerson searchMultiple = new SearchMultiplePerson(Convert.ToInt32(conn.MacSN), 0, "", "", 2, "0-100", 0, "", count * 10, 10, 0);
                            count++;
                            jsonBody <SearchMultiplePerson> jsonBodySearchMultiplePerson = new jsonBody <SearchMultiplePerson>("SearchPersonList", searchMultiple);
                            jsonString = JsonConvert.SerializeObject(jsonBodySearchMultiplePerson);
                            ret        = DeviceObject.objFK623.POST_GetResponse(searchMultipleUrl, conn.MacSeriesUserName, conn.SeaSeries_Pwd, ref jsonString);
                            if (!ret)
                            {
                                break;
                            }
                            jsonBody <SearchMultiplePersonInfo <SearchPersonInfo> > searchMultiplePersonInfo = JsonConvert.DeserializeObject <jsonBody <SearchMultiplePersonInfo <SearchPersonInfo> > >(jsonString);
                            {
                                for (int j = 0; j < searchMultiplePersonInfo.info.Listnum; j++)
                                {
                                    if (Stop || StopGet)
                                    {
                                        break;
                                    }
                                    vEnrollNumber = searchMultiplePersonInfo.info.List[j].CustomizeID;
                                    UserName      = searchMultiplePersonInfo.info.List[j].Name;
                                    if (!selStringList.Contains(vEnrollNumber.ToString()) && vEnrollNumber != 0)
                                    {
                                        //int index = this.cardGrid.Rows.Add();
                                        cardGrid.Rows.Add(new object[] { false, vEnrollNumber.ToString(), UserName });
                                        //// ((DataGridViewCheckBoxCell)cardGrid.Rows[index].Cells[0]).Value = true;
                                        //this.cardGrid.Rows[index].Cells[1].Value = vEnrollNumber.ToString();
                                        //this.cardGrid.Rows[index].Cells[2].Value = UserName;

                                        selStringList.Add(vEnrollNumber.ToString());

                                        lblMsg.Text = string.Format("{0}", cardGrid.Rows.Count);
                                    }
                                    //EnrollNumberCount++;

                                    lblMsg1.Text = Pub.GetResText(formCode, "btnGetListFromMac", "") + string.Format("-{0} /{1} ", cardGrid.Rows.Count, cardGrid.Rows.Count);
                                }
                            }
                            Application.DoEvents();
                        }
                        break;

                    case 3:
                        if (SystemInfo.ShowSTAR != 1)
                        {
                            Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "MsgUnModuleInfo", ""), Pub.GetResText(formCode, "StarDev", "")));
                            break;
                        }
                        if (RegisterInfo.IsValid || RegisterInfo.IsTest)
                        {
                            if (RegisterInfo.EndDate < DateTime.Now)
                            {
                                Pub.MessageBoxShow(RegisterInfo.StateText);
                                break;
                            }
                        }
                        try
                        {
                            if (DeviceObject.socKetClient.Open(conn.NetHost, conn.NetPort, conn.NetPassword))
                            {
                                string        cmd               = "GetDeviceInfo";
                                DeviceCmd     getDeviceCmd      = new DeviceCmd(cmd);
                                StringBuilder jsonStringBuilder = new StringBuilder(JsonConvert.SerializeObject(getDeviceCmd));
                                if (DeviceObject.socKetClient.SendData(ref jsonStringBuilder))
                                {
                                    cmd = "GetUserIdList";
                                    GetUserIdListCmd getUserIdListCmd = new GetUserIdListCmd(0);
                                    _DeviceCmd <GetUserIdListCmd> devGetUserIdListCmd = new _DeviceCmd <GetUserIdListCmd>(cmd, getUserIdListCmd);
RE:
                                    if (Stop || StopGet)
                                    {
                                        break;
                                    }
                                    jsonStringBuilder = new StringBuilder(JsonConvert.SerializeObject(devGetUserIdListCmd));
                                    if (DeviceObject.socKetClient.SendData(ref jsonStringBuilder))
                                    {
                                        int back = DeviceObject.socKetClient.JsonRecive(jsonStringBuilder);
                                        if (back == 0)
                                        {
                                            _ResultInfo <UserListInfo <UserIdName> > personIDList = JsonConvert.DeserializeObject <_ResultInfo <UserListInfo <UserIdName> > >(jsonStringBuilder.ToString());
                                            if (personIDList.result_data.users != null)
                                            {
                                                for (int x = 0; x < personIDList.result_data.users.Count; x++)
                                                {
                                                    int index = this.cardGrid.Rows.Add();
                                                    this.cardGrid.Rows[index].Cells[1].Value = personIDList.result_data.users[x].userId;
                                                    this.cardGrid.Rows[index].Cells[2].Value = personIDList.result_data.users[x].name;

                                                    selStringList.Add(personIDList.result_data.users[x].userId);
                                                    EnrollNumberCount = index;
                                                    lblMsg.Text       = string.Format("{0}", index);
                                                }
                                            }
                                            else
                                            {
                                                lblMsg.ForeColor = Color.FromName("red");
                                                lblMsg.Text      = (Pub.GetResText(formCode, "ErrorUnUserID", ""));
                                                ret = false;
                                                continue;
                                            }

                                            if (personIDList.result_data.packageId != 0)
                                            {
                                                devGetUserIdListCmd.data.packageId++;
                                                goto RE;
                                            }

                                            lblMsg1.Text = Pub.GetResText(formCode, "btnGetListFromMac", "") + string.Format("-{0} /{1} ", EnrollNumberCount, EnrollNumberCount);
                                            Application.DoEvents();
                                            ret = true;
                                        }
                                        else
                                        {
                                            ret = false;
                                        }
                                    }
                                    else
                                    {
                                        ret = false;
                                    }
                                }
                            }
                            else
                            {
                                lblMsg.ForeColor = Color.FromName("red");
                                lblMsg.Text      = DeviceObject.objFK623.GetRunMsg((int)enumErrorCode.RUNERR_NO_OPEN_COMM);
                                continue;
                            }
                            DeviceObject.socKetClient.Close();
                        }
                        catch (Exception E)
                        {
                            MessageBox.Show(E.Message);
                        }
                        break;

                    default:
                        SystemInfo.MacSeriesTypeId = 1;
                        DeviceObject.objFK623.InitConn(conn);
                        if (!DeviceObject.objFK623.IsOpen)
                        {
                            DeviceObject.objFK623.Open();
                        }
                        vnResultCode = DeviceObject.objFK623.EnableDevice(0);
                        state        = DeviceObject.objFK623.IsOpen;
                        if (state)
                        {
                            vnResultCode = DeviceObject.objFK623.ReadAllUserID();
                        }
                        else
                        {
                            lblMsg.ForeColor = Color.FromName("red");
                            lblMsg.Text      = DeviceObject.objFK623.GetRunMsg((int)enumErrorCode.RUNERR_NO_OPEN_COMM);
                        }

                        if (vnResultCode != (int)enumErrorCode.RUN_SUCCESS)
                        {
                            if (state)
                            {
                                lblMsg.ForeColor = Color.FromName("red");
                                lblMsg.Text      = (Pub.GetResText(formCode, "ErrorUnUserID", ""));
                            }
                            DeviceObject.objFK623.EnableDevice(1);
                            DeviceObject.objFK623.Close();
                            continue;
                        }

                        do
                        {
                            vnResultCode = DeviceObject.objFK623.GetAllUserID(
                                ref vEnrollNumber,
                                ref vBackupNumber,
                                ref vPrivilege,
                                ref vnEnableFlag);

                            if (vnResultCode != (int)enumErrorCode.RUN_SUCCESS)
                            {
                                DeviceObject.objFK623.EnableDevice(1);
                                DeviceObject.objFK623.Close();
                                break;
                            }
                            DeviceObject.objFK623.GetUserName(vEnrollNumber, ref UserName);
                            if (!selStringList.Contains(vEnrollNumber.ToString()) && vEnrollNumber != 0)
                            {
                                int index = this.cardGrid.Rows.Add();
                                // ((DataGridViewCheckBoxCell)cardGrid.Rows[index].Cells[0]).Value = true;
                                this.cardGrid.Rows[index].Cells[1].Value = vEnrollNumber.ToString();
                                this.cardGrid.Rows[index].Cells[2].Value = UserName;

                                selStringList.Add(vEnrollNumber.ToString());
                                EnrollNumberCount = index;
                                lblMsg.Text       = string.Format("{0}", index);
                            }
                            //EnrollNumberCount++;

                            lblMsg1.Text = Pub.GetResText(formCode, "btnGetListFromMac", "") + string.Format("-{0} /{1} ", EnrollNumberCount, EnrollNumberCount);
                            Application.DoEvents();
                            if (StopGet)
                            {
                                DeviceObject.objFK623.EnableDevice(1);
                                DeviceObject.objFK623.Close();
                                break;
                            }
                            if (Stop)
                            {
                                DeviceObject.objFK623.EnableDevice(1);
                                DeviceObject.objFK623.Close();
                                this.Close();
                            }
                        }while (true);
                        break;
                    }

                    cardGrid.Sort(this.cardGrid.Columns[1], ListSortDirection.Ascending);//排序
                    lblMsg.ForeColor      = Color.FromName("Black");
                    lblMsg.Text           = cardGrid.Rows.Count.ToString();
                    lblMsg1.Text          = Pub.GetResText(formCode, "MsgReadEndData", "");
                    progBar1.ProgressType = DevComponents.DotNetBar.eProgressItemType.Standard;
                    progBar1.Value        = 0;
                    StopGet          = false;
                    progBar1.Visible = false;
                    lblMsg1.Visible  = false;
                    btnStop.Visible  = false;
                }
            }
        }
Пример #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cbbLanguage.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorSelectCorrect", ""), lbLanguage.Text));
                return;
            }
            if (string.IsNullOrEmpty(cbbVerifyMode.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorSelectCorrect", ""), lbVerifyMode.Text));
                return;
            }

            if (string.IsNullOrEmpty(cbbWiegandType.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorSelectCorrect", ""), lbWiegandType.Text));
                return;
            }
            if (string.IsNullOrEmpty(cbbVolume.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorSelectCorrect", ""), lbVolume.Text));
                return;
            }

            if (string.IsNullOrEmpty(txtOpenDoorDelay.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbOpenDoorDelay.Text));
                txtOpenDoorDelay.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtAlarmDelay.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbAlarmDelay.Text));
                txtAlarmDelay.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtReverifyTime.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbReverifyTime.Text));
                txtReverifyTime.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtScreensaversTime.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbScreensaversTime.Text));
                txtScreensaversTime.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtSleepTime.Text))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbSleepTime.Text));
                txtSleepTime.Focus();
                return;
            }

            string deviceName       = txtDevName.Text.Trim();
            string wiegandType      = cbbWiegandType.Text;
            string language         = ((LanguageType)cbbLanguage.SelectedItem).id;
            string volume           = cbbVolume.Text;
            string antiPass         = "";
            string openDoorDelay    = txtOpenDoorDelay.Text.Trim();
            string tamperAlarm      = "";
            string alarmDelay       = txtAlarmDelay.Text.Trim();
            string reverifyTime     = txtReverifyTime.Text.Trim();
            string screensaversTime = txtScreensaversTime.Text.Trim();
            string sleepTime        = txtSleepTime.Text.Trim();
            string verifyMode       = ((StarVerifyModeType)cbbVerifyMode.SelectedItem).id;

            if (chkAntiPass.Checked)
            {
                antiPass = "******";
            }
            else
            {
                antiPass = "******";
            }

            if (chkTamperAlarm.Checked)
            {
                tamperAlarm = "yes";
            }
            else
            {
                tamperAlarm = "no";
            }

            string cmd = "SetDeviceSetting";
            string sql = "";

            try
            {
                if (MacSN == "")
                {
                    sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "22", "1", deviceName, wiegandType, language,
                                                                      antiPass, openDoorDelay, tamperAlarm, alarmDelay, volume, reverifyTime, screensaversTime,
                                                                      sleepTime, verifyMode });
                }
                else
                {
                    sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "23", deviceName, wiegandType, language,
                                                                      antiPass, openDoorDelay, tamperAlarm, alarmDelay, volume, reverifyTime, screensaversTime,
                                                                      sleepTime, verifyMode, MacSN });
                }

                if (SystemInfo.db.ExecSQL(sql) >= 0)
                {
                    ParameterInfo parameterInfoCmd = new ParameterInfo(deviceName, wiegandType, language, volume, antiPass,
                                                                       openDoorDelay, tamperAlarm, alarmDelay, reverifyTime, screensaversTime, sleepTime, verifyMode);
                    _DeviceCmd <ParameterInfo> devParameterInfoCmd = new _DeviceCmd <ParameterInfo>(cmd, parameterInfoCmd);
                    StringBuilder jsonStringBuilder = new StringBuilder(JsonConvert.SerializeObject(devParameterInfoCmd));
                    frmMJStarOprt frm = new frmMJStarOprt(this.Text, btnOk.Text, jsonStringBuilder, 1, null);
                    frm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Pub.ShowErrorMsg(ex, sql);
            }
        }
Пример #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string serverHost     = txtServerHost.Text.Trim();
            string serverPort     = txtServerPort.Text.Trim();
            string pushServerHost = txtPushServerHost.Text.Trim();
            string pushServerPort = txtPushServerPort.Text.Trim();
            string interval       = txtInterval.Text.Trim();

            if (string.IsNullOrEmpty(serverHost))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbServerHost.Text));
                txtServerHost.Focus();
                return;
            }
            if (string.IsNullOrEmpty(serverPort))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbServerPort.Text));
                txtServerPort.Focus();
                return;
            }
            if (string.IsNullOrEmpty(pushServerHost))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbPushServerHost.Text));
                txtPushServerHost.Focus();
                return;
            }
            if (string.IsNullOrEmpty(pushServerPort))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbPushServerPort.Text));
                txtPushServerPort.Focus();
                return;
            }
            if (string.IsNullOrEmpty(interval))
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "ErrorEnterCorrect", ""), lbInterval.Text));
                txtInterval.Focus();
                return;
            }

            string pushEnable = "";

            if (chkPushEnable.Checked)
            {
                pushEnable = "yes";
            }
            else
            {
                pushEnable = "no";
            }
            string cmd = "SetDeviceSetting";
            string sql = "";

            try
            {
                if (MacSN == "")
                {
                    sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "24", "1", serverHost, serverPort, pushServerHost, pushServerPort, interval, pushEnable });
                }
                else
                {
                    sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "25", serverHost, serverPort, pushServerHost, pushServerPort, interval, pushEnable, MacSN });
                }


                if (SystemInfo.db.ExecSQL(sql) >= 0)
                {
                    NetParameterInfo parameterInfoCmd = new NetParameterInfo(serverHost, serverPort, pushServerHost, pushServerPort, interval, pushEnable);
                    _DeviceCmd <NetParameterInfo> devParameterInfoCmd = new _DeviceCmd <NetParameterInfo>(cmd, parameterInfoCmd);
                    StringBuilder jsonStringBuilder = new StringBuilder(JsonConvert.SerializeObject(devParameterInfoCmd));
                    frmMJStarOprt frm = new frmMJStarOprt(this.Text, btnOk.Text, jsonStringBuilder, 1, null);
                    frm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Pub.ShowErrorMsg(ex, sql);
            }
        }