Esempio n. 1
0
        /// <summary>
        /// 清除最近保存的抓拍图片信息
        /// </summary>
        /// <param name="video">摄像机</param>
        public void ClearSnapShot(VideoSourceInfo video)
        {
            VideoPanel vp = videoGrid.VideoPanelCollection.SingleOrDefault(v => (v.VideoSource == video));

            if (vp != null)
            {
                vp.ClearSnapShot();
            }
        }
Esempio n. 2
0
        public void ProcessReport(ReportBase r)
        {
            ParkInfo park = ParkBuffer.Current.GetPark(r.ParkID);

            if (park != null && park.RootParkID > 0)
            {
                park = ParkBuffer.Current.GetPark(park.RootParkID);
            }
            if (park == null)
            {
                return;
            }
            if (park.HostWorkstation == WorkStationInfo.CurrentStation.StationID) //如果本机是停车场的通讯主机,则它要负责抓拍图片
            {
                EntranceInfo entrance = ParkBuffer.Current.GetEntrance(r.EntranceID);
                if (entrance != null)
                {
                    foreach (VideoSourceInfo video in entrance.VideoSources)
                    {
                        if (r is CarSenseReport)
                        {
                            CarSenseReport cp = r as CarSenseReport;
                            if (cp.InOrOutFlag == 1)  //车到时打开视频
                            {
                                VideoPanel vp = videoGrid.VideoPanelCollection.SingleOrDefault(v => (v.VideoSource == video));
                                if (vp != null)
                                {
                                    if (UserSetting.Current.SnapshotWhenCarArrive)  //车压地感时抓拍图片
                                    {
                                        string path = Path.Combine(TempFolderManager.GetCurrentFolder(),
                                                                   string.Format("{0}_{1}_{2}.jpg", "CarArrive", Guid.NewGuid().ToString(), video.VideoID));
                                        if (SnapShotTo(video, ref path, false, false))
                                        {
                                            SnapShot      shot    = new SnapShot(cp.EventDateTime, video.VideoID, string.Empty, path);
                                            string        master  = AppSettings.CurrentSetting.ImageDBConnStr;
                                            string        standby = AppSettings.CurrentSetting.CurrentStandbyConnect;
                                            CommandResult result  = (new SnapShotBll(master)).Insert(shot);
                                            if (result.Result != ResultCode.Successful && !string.IsNullOrEmpty(standby))
                                            {
                                                (new SnapShotBll(standby)).Insert(shot);
                                            }

                                            //(new SnapShotBll(AppSettings.CurrentSetting.ParkConnect)).Insert(shot);
                                        }
                                        else
                                        {
                                            if (AppSettings.CurrentSetting.Debug)
                                            {
                                                string logmsg = string.Format("【{0}】车压地感时抓拍图片失败 ", vp.VideoSource.VideoName);
                                                Ralid.GeneralLibrary.LOG.FileLog.Log("FrmSnapShoter", logmsg);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        vp.OpenForSnapshot(true);
                                    }
                                }
                            }
                            else
                            {
                                if (AppSettings.CurrentSetting.Optimized)  //启用视频优化车走时关闭视频
                                {
                                    VideoPanel vp = videoGrid.VideoPanelCollection.SingleOrDefault(v => (v.VideoSource == video));
                                    if (vp != null)
                                    {
                                        vp.Close();
                                    }
                                }
                            }
                        }
                        else if (r is CardEventReport)
                        {
                            CardEventReport cardEvent = r as CardEventReport;
                            if (cardEvent.EventStatus == CardEventStatus.Valid)
                            {
                                VideoPanel vp = videoGrid.VideoPanelCollection.SingleOrDefault(v => (v.VideoSource == video));
                                if (vp != null) //如果视频已经抓拍了一张,则此次用同一张图
                                {
                                    object tag = null;
                                    lock (_TagLocker)  //加锁是防止多个线程同时写
                                    {
                                        tag    = vp.Tag;
                                        vp.Tag = null;
                                    }
                                    if (tag != null)
                                    {
                                        string path = tag.ToString();
                                        if (path != "fail")
                                        {
                                            SnapShot      shot    = new SnapShot(cardEvent.EventDateTime, video.VideoID, cardEvent.CardID, path);
                                            string        master  = AppSettings.CurrentSetting.ImageDBConnStr;
                                            string        standby = AppSettings.CurrentSetting.CurrentStandbyConnect;
                                            CommandResult result  = (new SnapShotBll(master)).Insert(shot);
                                            if (result.Result != ResultCode.Successful && !string.IsNullOrEmpty(standby))
                                            {
                                                (new SnapShotBll(standby)).Insert(shot);
                                            }

                                            //(new SnapShotBll(AppSettings.CurrentSetting.ParkConnect)).Insert(shot);
                                        }
                                        else
                                        {
                                            if (AppSettings.CurrentSetting.Debug)
                                            {
                                                string logmsg = string.Format("【{0}】刷卡事件之前的视频抓拍失败,无图片 ", vp.VideoSource.VideoName);
                                                Ralid.GeneralLibrary.LOG.FileLog.Log("FrmSnapShoter", logmsg);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        string path = Path.Combine(TempFolderManager.GetCurrentFolder(),
                                                                   string.Format("{0}_{1}_{2}.jpg", "CardEvent", Guid.NewGuid().ToString(), video.VideoID));
                                        if (SnapShotTo(video, ref path, false, false))
                                        {
                                            SnapShot      shot    = new SnapShot(cardEvent.EventDateTime, video.VideoID, cardEvent.CardID, path);
                                            string        master  = AppSettings.CurrentSetting.ImageDBConnStr;
                                            string        standby = AppSettings.CurrentSetting.CurrentStandbyConnect;
                                            CommandResult result  = (new SnapShotBll(master)).Insert(shot);
                                            if (result.Result != ResultCode.Successful && !string.IsNullOrEmpty(standby))
                                            {
                                                (new SnapShotBll(standby)).Insert(shot);
                                            }

                                            //(new SnapShotBll(AppSettings.CurrentSetting.ParkConnect)).Insert(shot);
                                        }
                                        else
                                        {
                                            if (AppSettings.CurrentSetting.Debug)
                                            {
                                                string logmsg = string.Format("【{0}】刷卡事件抓拍图片失败 ", vp.VideoSource.VideoName);
                                                Ralid.GeneralLibrary.LOG.FileLog.Log("FrmSnapShoter", logmsg);
                                            }
                                        }
                                    }

                                    vp.ClearSnapShot();//清空抓拍图片信息
                                }
                            }
                        }
                        else if (r is AlarmReport)
                        {
                            AlarmReport ar = r as AlarmReport;
                            if (ar.AlarmType == Ralid.Park.BusinessModel.Enum.AlarmType.Opendoor ||
                                ar.AlarmType == Ralid.Park.BusinessModel.Enum.AlarmType.GateAlarm)
                            {
                                string path = Path.Combine(TempFolderManager.GetCurrentFolder(),
                                                           string.Format("{0}_{1}_{2}.jpg", "OpenDoor", Guid.NewGuid().ToString(), video.VideoID));
                                if (SnapShotTo(video, ref path, false, true))
                                {
                                    //这里清除抓拍图片信息,是因为使用信路通或大华进行抓拍时,会保存抓拍图片和识别到的车牌,如果不清除,有可能会用到下一辆车上
                                    ClearSnapShot(video);
                                    SnapShot      shot    = new SnapShot(ar.EventDateTime, video.VideoID, string.Empty, path);
                                    string        master  = AppSettings.CurrentSetting.ImageDBConnStr;
                                    string        standby = AppSettings.CurrentSetting.CurrentStandbyConnect;
                                    CommandResult result  = (new SnapShotBll(master)).Insert(shot);
                                    if (result.Result != ResultCode.Successful && !string.IsNullOrEmpty(standby))
                                    {
                                        (new SnapShotBll(standby)).Insert(shot);
                                    }

                                    //(new SnapShotBll(AppSettings.CurrentSetting.ParkConnect)).Insert(shot);
                                }
                                else
                                {
                                    if (AppSettings.CurrentSetting.Debug)
                                    {
                                        string logmsg = string.Format("【{0}】报警抓拍图片失败 ", video.VideoName);
                                        Ralid.GeneralLibrary.LOG.FileLog.Log("FrmSnapShoter", logmsg);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }