private void DoCaptureImage(DoorCameraObject dco, ControllerState state)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
            {
                try
                {
                    var image = dco.camera.GetEngine().CaptureImage();
                    if (image == null)
                    {
                        log.Error("抓拍失败:" + dco.camera.IP);
                        return;
                    }
                    DateTime dt   = DateTime.Now;
                    string camstr = "";
                    if (!string.IsNullOrWhiteSpace(dco.camera.IP))
                    {
                        camstr = dco.camera.IP.Replace('.', '_');
                    }
                    else
                    {
                        camstr = "camera_null_ip";
                    }
                    string filePath = camstr + "\\" + dt.Year + "\\" + dt.Month + "\\" + dt.Day;
                    string fullPath = Path.Combine(ImageFolder, filePath);
                    if (!Directory.Exists(fullPath))
                    {
                        Directory.CreateDirectory(fullPath);
                    }

                    string pathName = Path.Combine(filePath, dt.ToString("yyyyMMddHHmmss_fff") + ".jpg");
                    fullPath        = Path.Combine(ImageFolder, pathName);
                    image.Save(fullPath, System.Drawing.Imaging.ImageFormat.Jpeg);
                    image.Dispose();
                    Maticsoft.BLL.SMT_RECORDCAP_IMAGE sriBll     = new Maticsoft.BLL.SMT_RECORDCAP_IMAGE();
                    Maticsoft.Model.SMT_RECORDCAP_IMAGE sriModel = new Maticsoft.Model.SMT_RECORDCAP_IMAGE();

                    sriModel.CAP_RELATIVE_URL = pathName;
                    sriModel.CAP_TIME         = dt;
                    sriModel.CTRL_SN          = dco.controller.sn;
                    sriModel.RECORD_INDEX     = state.lastRecordIndex;
                    sriModel.RECORD_TIME      = state.recordTime;

                    sriBll.Add(sriModel);
                }
                catch (Exception ex)
                {
                    log.Error("抓拍失败:" + dco.camera.IP, ex);
                }
            }));
        }
        private void DoLoadCtrlr()
        {
            try
            {
                log.Info("加载抓拍配置...");
                string    sql = "SELECT SDC.*,SDI.CTRL_ID,SDI.CTRL_DOOR_INDEX,SCI.*,SCIF.* FROM SMT_DOOR_CAMERA SDC INNER JOIN SMT_DOOR_INFO SDI ON SDC.DOOR_ID=SDI.ID INNER JOIN SMT_CAMERA_INFO SCI ON SDC.CAMERA_ID=SCI.ID INNER JOIN SMT_CONTROLLER_INFO SCIF ON SDI.CTRL_ID=SCIF.ID WHERE SDC.ENABLE_CAP=1";
                DataTable dt  = Maticsoft.DBUtility.DbHelperSQL.Query(sql).Tables[0];
                doorCameraObjects.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        DoorCameraObject   dco   = new DoorCameraObject();
                        Controller         ctrlr = new Controller();
                        ControllerDoorType type  = ControllerDoorType.TwoDoorsTwoDirections;
                        Enum.TryParse <ControllerDoorType>(Convert.ToString(dr["CTRLR_TYPE"]), out type);
                        ctrlr.doorType          = type;
                        ctrlr.driverReleaseTime = dr["DRIVER_DATE"] == null ? DateTime.MinValue : (DateTime)dr["DRIVER_DATE"];
                        ctrlr.driverVersion     = Convert.ToString(dr["DRIVER_VERSION"]);
                        ctrlr.gateway           = Convert.ToString(dr["GATEWAY"]);
                        ctrlr.id       = dr["CTRL_ID"] == null ? -1 : (decimal)dr["CTRL_ID"];
                        ctrlr.ip       = Convert.ToString(dr["IP"]);
                        ctrlr.mac      = Convert.ToString(dr["MAC"]);
                        ctrlr.mask     = Convert.ToString(dr["MASK"]);
                        ctrlr.model    = Convert.ToString(dr["CTRLR_MODEL"]);
                        ctrlr.port     = dr["PORT"] == null ? 60000 : (int)dr["PORT"];
                        ctrlr.sn       = Convert.ToString(dr["SN_NO"]);
                        dco.controller = ctrlr;

                        IPCamera camera = new IPCamera();
                        camera.CapturePort = dr["CAMERA_CAP_PORT"] == null ? 80 : (int)dr["CAMERA_CAP_PORT"];
                        CapType ct = CapType.Onvif;
                        Enum.TryParse <CapType>(Convert.ToString(dr["CAMERA_CAP_TYPE"]), out ct);
                        camera.CapType = ct;
                        camera.IP      = Convert.ToString(dr["CAMERA_IP"]);
                        CameraModel model = CameraModel.None;
                        Enum.TryParse <CameraModel>(Convert.ToString(dr["CAMERA_MODEL"]), out model);
                        camera.Model        = model;
                        camera.Password     = Convert.ToString(dr["CAMERA_PWD"]);
                        camera.Port         = dr["CAMERA_PORT"] == null ? 80 : (int)dr["CAMERA_PORT"];
                        camera.User         = Convert.ToString(dr["CAMERA_USER"]);
                        dco.camera          = camera;
                        dco.ctrl_door_index = dr["CTRL_DOOR_INDEX"] == null ? 1 : (byte)dr["CTRL_DOOR_INDEX"];

                        doorCameraObjects.Add(dco);
                    }
                    catch (Exception ex)
                    {
                        log.Error("加载抓拍配置异常:DOOR_ID=" + dr["DOOR_ID"] + ",CAMERA_IP=" + dr["CAMERA_IP"], ex);
                    }
                }
                List <string> sns    = new List <string>();
                var           curSNs = watchService.GetControllerSNs();
                foreach (var item in doorCameraObjects)
                {
                    if (!curSNs.Contains(item.controller.sn))
                    {
                        sns.Add(item.controller.sn);
                    }
                }
                foreach (var item in curSNs)
                {
                    if (!sns.Contains(item))
                    {
                        watchService.RemoveController(item);
                    }
                }
                foreach (var item in doorCameraObjects)
                {
                    watchService.AddController(item.controller, ControllerStateCallBack, "test");
                }
            }
            catch (Exception ex)
            {
                log.Error("读取抓拍配置异常:", ex);
            }
        }