Пример #1
0
        public Dictionary <int, EventRect> GetEventRectCustom(ref string errMessage, int objectid)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            Dictionary <int, EventRect> list = new Dictionary <int, EventRect>();

            try
            {
                DataSet   ds = EventRectDataAccess.GetEventRectCustom(db, objectid);
                EventRect eventrect;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    eventrect = new EventRect(ds.Tables[0].Rows[i]);
                    list.Add(eventrect.EventRectId, eventrect);
                }
                return(list);
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(null);
            }
        }
Пример #2
0
        public static int Insert(Database db, EventRect oEventRect)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();

            sbField.Append("INSERT INTO  [EvenRectInfo](");
            sbValue.Append("values (");
            //sbField.Append("[FaceID]");
            //sbValue.AppendFormat("'{0}'", oFace.FaceID);
            sbField.Append("[x]");
            sbValue.AppendFormat("{0}", oEventRect.x);
            sbField.Append(",[y]");
            sbValue.AppendFormat(",{0}", oEventRect.y);
            sbField.Append(",[w]");
            sbValue.AppendFormat(",{0}", oEventRect.w);
            sbField.Append(",[h]");
            sbValue.AppendFormat(",{0}", oEventRect.h);
            sbField.Append(",[ObjectId])");
            sbValue.AppendFormat(",{0})", oEventRect.ObjectId);
            string cmdText = sbField.ToString() + " " + sbValue.ToString();

            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                db.ExecuteNonQuery(CommandType.Text, cmdText);
                int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT     ident_current('EventRectInfo')").ToString());
                return(id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public int Insert(ref string errMessage, EventRect oEventRect)
        {
            Database db = DatabaseFactory.CreateDatabase();

            errMessage = "";
            try
            {
                return(EventRectDataAccess.Insert(db, oEventRect));
            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return(-1);
            }
        }
Пример #4
0
        public void Handle(byte[] bytes)
        {
            try
            {
                logger.Info("开始解析事件数据");

                //获取xml
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(BitConverter.ToString(bytes, 4));

                string      errMessage = "";
                int         cameraid;
                int         pictureid = 0;
                int         eventid;
                int         objid;
                DateTime    timeid;
                XmlNodeList xml_cameras;
                xml_cameras = xmlDocument.SelectSingleNode("/pr/cameras").ChildNodes;
                foreach (XmlNode xmlItem in xml_cameras)
                {
                    XmlElement camera = (XmlElement)xmlItem;
                    cameraid = Convert.ToInt32(camera.GetAttribute("id"));
                    timeid   = new DateTime(long.Parse(camera.GetAttribute("timeid")));
                    if (!CapturePictureBusiness.Instance.IsExistCapturePicture(ref errMessage, cameraid, timeid))
                    {
                        //将改图像从TempPicture表移动到CapturePicture//先获取临时图像GetTempPicture,再移动图像MoveTempPicture
                        //图像还在临时图像库中
                        TempPicture    tempPicture          = TempPictureBusiness.Instance.GetTempPicture(ref errMessage, cameraid, timeid);
                        string         destFile             = TempPictureBusiness.Instance.MoveTempPicture(ref errMessage, tempPicture);
                        CapturePicture capturePictureinsert = new CapturePicture()
                        {
                            CameraID = cameraid, Datetime = timeid, FilePath = destFile
                        };
                        pictureid = CapturePictureBusiness.Instance.Insert(ref errMessage, capturePictureinsert);
                    }

                    CapturePicture oCapturePicture = CapturePictureBusiness.Instance.GetCapturePicture(ref errMessage, cameraid, timeid);

                    Event ev = new Event();
                    ev.CarNum     = Convert.ToInt32(camera.GetAttribute("CarNum"));
                    ev.Congestion = Convert.ToInt32(camera.GetAttribute("Congestion"));
                    ev.PictureID  = pictureid;
                    eventid       = EventBusiness.Instance.Insert(ref errMessage, ev);

                    XmlNodeList objectlist = xmlItem.ChildNodes;
                    foreach (XmlNode xmlitem1 in objectlist)
                    {
                        XmlElement objecttarget = (XmlElement)xmlitem1;
                        ObjectInfo obj          = new ObjectInfo();
                        if (Convert.ToInt32(objecttarget.GetAttribute("stop")) == 1)
                        {
                            obj.stop = true;
                        }
                        else
                        {
                            obj.stop = false;
                        }
                        if (Convert.ToInt32(objecttarget.GetAttribute("illegalDir")) == 1)
                        {
                            obj.illegalDir = true;
                        }
                        else
                        {
                            obj.illegalDir = false;
                        }
                        if (Convert.ToInt32(objecttarget.GetAttribute("CrossLine")) == 1)
                        {
                            obj.CrossLine = true;
                        }
                        else
                        {
                            obj.CrossLine = false;
                        }
                        if (Convert.ToInt32(objecttarget.GetAttribute("changeChannel")) == 1)
                        {
                            obj.changeChannel = true;
                        }
                        else
                        {
                            obj.changeChannel = false;
                        }
                        obj.EventId = eventid;
                        objid       = ObjectBusiness.Instance.Insert(ref errMessage, obj);
                        foreach (XmlNode rectitem in objecttarget.ChildNodes)
                        {
                            XmlElement rectelement = (XmlElement)rectitem;
                            EventRect  myrect      = new EventRect();
                            myrect.x        = Convert.ToInt32(rectelement.GetAttribute("x"));
                            myrect.y        = Convert.ToInt32(rectelement.GetAttribute("y"));
                            myrect.w        = Convert.ToInt32(rectelement.GetAttribute("w"));
                            myrect.h        = Convert.ToInt32(rectelement.GetAttribute("h"));
                            myrect.ObjectId = objid;
                            EventRectBusiness.Instance.Insert(ref errMessage, myrect);
                        }
                    }
                }

                /*******************处理流程:
                 *
                 * 1)解析xml文件,获取cameraid和DateTime
                 * 2)根据cameraid和DateTime判断改图像是否已经进入CapturePicture表
                 * 3)如果是;转5;
                 * 4)如果否,将改图像从TempPicture表移动到CapturePicture//先获取临时图像GetTempPicture,再移动图像MoveTempPicture
                 * 5)识别结果入库
                 */


                logger.Info("结束解析事件数据");
            }
            catch (Exception ex)
            {
                logger.Error("解析事件数据错误:" + FromASCIIByteArray(bytes));
            }
        }