Esempio n. 1
0
        private void listViewTimeSegment_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            iItemIndex = e.ItemIndex;
            if (iItemIndex < 0)
            {
                return;
            }

            int i = iItemIndex;

            if (1 == m_struPlanCfg.struPlanCfg[i].byEnable)
            {
                checkBoxEnable.Checked = true;
            }
            else
            {
                checkBoxEnable.Checked = false;
            }
            comboBoxDoorStateMode.SelectedIndex    = (int)m_struPlanCfg.struPlanCfg[i].byDoorStatus;
            comboBoxVerificationMode.SelectedIndex = (int)m_struPlanCfg.struPlanCfg[i].byVerifyMode;
            CHCNetSDK.NET_DVR_SIMPLE_DAYTIME struTime = new CHCNetSDK.NET_DVR_SIMPLE_DAYTIME();
            if (AcsDemoPublic.CheckDate(m_struPlanCfg.struPlanCfg[i].struTimeSegment.struBeginTime))
            {
                struTime = m_struPlanCfg.struPlanCfg[i].struTimeSegment.struBeginTime;
                if (struTime.byHour == 24 && struTime.byMinute == 0 && struTime.bySecond == 0)
                {
                    struTime.byHour   = 23;
                    struTime.byMinute = 59;
                    struTime.bySecond = 59;
                }
                dateTimePickerStartTime.Value = new System.DateTime(dateTimePickerStartTime.Value.Year,
                                                                    dateTimePickerStartTime.Value.Month, dateTimePickerStartTime.Value.Day, struTime.byHour,
                                                                    struTime.byMinute, struTime.bySecond);
            }
            if (AcsDemoPublic.CheckDate(m_struPlanCfg.struPlanCfg[i].struTimeSegment.struEndTime))
            {
                struTime = m_struPlanCfg.struPlanCfg[i].struTimeSegment.struEndTime;
                if (struTime.byHour == 24 && struTime.byMinute == 0 && struTime.bySecond == 0)
                {
                    struTime.byHour   = 23;
                    struTime.byMinute = 59;
                    struTime.bySecond = 59;
                }
                dateTimePickerEndTime.Value = new System.DateTime(dateTimePickerEndTime.Value.Year,
                                                                  dateTimePickerEndTime.Value.Month, dateTimePickerEndTime.Value.Day, struTime.byHour,
                                                                  struTime.byMinute, struTime.bySecond);
            }
        }
        private void SavePcituresAndFP(ref CSearchTaskResponse cSearchTaskResponse, ref MessageData m)
        {
            foreach (CDataCollections data in cSearchTaskResponse.SearchTaskResponse.DataCollections)
            {
                if (data.FingerprintList != null)
                {
                    foreach (CFingerprintList fp in data.FingerprintList)
                    {
                        byte[] bytes   = Convert.FromBase64String(fp.fingerprint);
                        string strPath = string.Format("{0}\\{1}_{2}_{3} fingerprint{4}.dat", Environment.CurrentDirectory, data.captureNo, data.name, data.employeeNo, fp.fingerprintID);
                        AcsDemoPublic.WriteBytesToFile(bytes, bytes.Length, strPath);
                    }
                }

                if (m.pictureLen > 0)
                {
                    string strPicPath = string.Format("{0}\\{1}_{2}_{3} facePicture.jpg", Environment.CurrentDirectory, data.captureNo, data.name, data.employeeNo);
                    AcsDemoPublic.WriteBytesToFile(m.picture, m.pictureLen, strPicPath);
                    if (!picDic.ContainsKey(data.captureNo))
                    {
                        picDic.Add(data.captureNo, strPicPath);
                    }
                }

                if (m.infraredPicLen > 0)
                {
                    string strInfraedPicPath = string.Format("{0}\\{1}_{2}_{3} infraredFacePicture.jpg", Environment.CurrentDirectory, data.captureNo, data.name, data.employeeNo);
                    AcsDemoPublic.WriteBytesToFile(m.infraredPic, m.infraredPicLen, strInfraedPicPath);
                    if (!infraredPicDic.ContainsKey(data.captureNo))
                    {
                        infraredPicDic.Add(data.captureNo, strInfraedPicPath);
                    }
                }

                if (data.FaceFeature != null)
                {
                    CFaceFeatureSingle cSingle = new CFaceFeatureSingle();
                    cSingle.FaceFeature = data.FaceFeature;
                    string strSigle = JsonConvert.SerializeObject(cSingle);
                    if (!featureDic.ContainsKey(data.captureNo))
                    {
                        featureDic.Add(data.captureNo, strSigle);
                    }
                }
            }
        }
Esempio n. 3
0
        private void buttonGet_Click(object sender, EventArgs e)
        {
            uint dwCommand = 0;

            string[] strCommand = { "NET_DVR_GET_DOOR_STATUS_HOLIDAY_PLAN", "NET_DVR_GET_VERIFY_HOLIDAY_PLAN", "NET_DVR_GET_CARD_RIGHT_HOLIDAY_PLAN_V50" };

            uint   dwReturned = 0;
            string strTemp    = null;
            uint   dwSize     = (uint)Marshal.SizeOf(m_struPlanCfgH);

            m_struPlanCfgH.dwSize = dwSize;
            IntPtr ptrPlanCfgH = Marshal.AllocHGlobal((int)dwSize);

            Marshal.StructureToPtr(m_struPlanCfgH, ptrPlanCfgH, false);

            switch (comboBoxDeviceType.SelectedIndex)
            {
            case 0:
            case 1:
                if (comboBoxDeviceType.SelectedIndex == 0)
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_DOOR_STATUS_HOLIDAY_PLAN;
                }
                else
                {
                    dwCommand = (uint)CHCNetSDK.NET_DVR_GET_VERIFY_HOLIDAY_PLAN;
                }

                int holidayPlanNumberIndex;
                int.TryParse(textBoxHolidayPlanNumber.Text, out holidayPlanNumberIndex);

                if (!CHCNetSDK.NET_DVR_GetDVRConfig(m_lUserID, dwCommand, holidayPlanNumberIndex, ptrPlanCfgH, dwSize, ref dwReturned))
                {
                    Marshal.FreeHGlobal(ptrPlanCfgH);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[comboBoxDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    strTemp = string.Format("{0}", strCommand[comboBoxDeviceType.SelectedIndex]);
                    g_formList.AddLog(m_lUserID, AcsDemoPublic.OPERATION_SUCC_T, strTemp);
                }

                break;

            case 2:
                dwCommand = (uint)CHCNetSDK.NET_DVR_GET_CARD_RIGHT_HOLIDAY_PLAN_V50;
                uint dwConSize = (uint)Marshal.SizeOf(m_struPlanCond);
                m_struPlanCond.dwSize = dwConSize;
                IntPtr ptrPlanCon = Marshal.AllocHGlobal((int)dwConSize);
                Marshal.StructureToPtr(m_struPlanCond, ptrPlanCon, false);
                IntPtr ptrDwReturned = Marshal.AllocHGlobal(4);

                // limited input data guarantee parse success
                uint.TryParse(textBoxHolidayPlanNumber.Text, out m_struPlanCond.dwHolidayPlanNumber);
                ushort.TryParse(textBoxLocalControllerID.Text, out m_struPlanCond.wLocalControllerID);


                if (!CHCNetSDK.NET_DVR_GetDeviceConfig(m_lUserID, dwCommand, 1, ptrPlanCon, dwConSize, ptrDwReturned, ptrPlanCfgH, dwSize))
                {
                    Marshal.FreeHGlobal(ptrPlanCfgH);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    strTemp = string.Format("{0} FAIL, ERROR CODE {1}", strCommand[comboBoxDeviceType.SelectedIndex], CHCNetSDK.NET_DVR_GetLastError());
                    MessageBox.Show(strTemp);
                    return;
                }
                else
                {
                    dwReturned = (uint)Marshal.ReadInt32(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrDwReturned);
                    Marshal.FreeHGlobal(ptrPlanCon);
                    strTemp = string.Format("{0}", strCommand[comboBoxDeviceType.SelectedIndex]);
                    g_formList.AddLog(m_lUserID, AcsDemoPublic.OPERATION_SUCC_T, strTemp);
                }

                break;

            default:
                Marshal.FreeHGlobal(ptrPlanCfgH);
                MessageBox.Show("unknown command");
                return;
            }

            m_struPlanCfgH = (CHCNetSDK.NET_DVR_HOLIDAY_PLAN_CFG)Marshal.PtrToStructure(ptrPlanCfgH, typeof(CHCNetSDK.NET_DVR_HOLIDAY_PLAN_CFG));

            UpdateList();

            if (1 == m_struPlanCfgH.byEnable)
            {
                checkBoxEnablePlan.Checked = true;
            }
            else
            {
                checkBoxEnablePlan.Checked = false;
            }

            if (!AcsDemoPublic.CheckState(m_struPlanCfgH.struBeginDate) || !AcsDemoPublic.CheckState(m_struPlanCfgH.struEndDate))
            {
                Marshal.FreeHGlobal(ptrPlanCfgH);
                return;
            }

            // set the date
            dateTimePickerStartDateHP.Value = new System.DateTime(m_struPlanCfgH.struBeginDate.wYear, m_struPlanCfgH.struBeginDate.byMonth, m_struPlanCfgH.struBeginDate.byDay);
            dateTimePickerEndDateHP.Value   = new System.DateTime(m_struPlanCfgH.struEndDate.wYear, m_struPlanCfgH.struEndDate.byMonth, m_struPlanCfgH.struEndDate.byDay);

            Marshal.FreeHGlobal(ptrPlanCfgH);
        }