private void btnAddCurve_Click(object sender, EventArgs e)
        {
            Global.nCurStatus = 1;
            SwithFormStat(1);
            foreach (ClsNVRInfo nvr in Global.nvrList)
            {
                if (nvr.nvrName == Global.sCurSelectedNvrName)
                {
                    foreach (ClsVideoChannel video in Global.videoList)
                    {
                        if (video.channelNo == Global.nCurSelectedVideoChan)
                        {
                            return;
                        }
                    }
                    ClsVideoChannel videoChan = new ClsVideoChannel();
                    int             i         = Global.nCurSelectedVideoChan;
                    videoChan.ip         = System.Text.Encoding.Default.GetString(nvr.config.struIPDevInfo[i].struIP.sIpV4);
                    videoChan.channelNo  = Global.nCurSelectedVideoChan;
                    videoChan.loginName  = System.Text.Encoding.Default.GetString(nvr.config.struIPDevInfo[i].sUserName);
                    videoChan.password   = System.Text.Encoding.Default.GetString(nvr.config.struIPDevInfo[i].sPassword);
                    videoChan.port       = nvr.config.struIPDevInfo[i].wDVRPort;
                    videoChan.streamType = nvr.config.struStreamMode[i].byGetStreamType;
                    videoChan.parentID   = nvr.id;
                    videoChan.id         = Global.mysqlHelper.ExecuteSql(videoChan.getInsertString());

                    Global.videoList.Add(videoChan);
                    nvr.videoList.Add(videoChan);
                }
            }
        }
Example #2
0
        private bool GetVideoListFromDB()
        {
            string queryString = "select * from vch ";

            try
            {
                Global.videoList.Clear();
                DataTable dt = Global.mysqlHelper.GetDataTable(queryString);
                if (dt == null || dt.Rows.Count < 1)
                {
                    return(true);
                }
                foreach (DataRow dr in dt.Rows)
                {
                    ClsVideoChannel video = new ClsVideoChannel();
                    video.id         = int.Parse(dr["id"].ToString());
                    video.channelNo  = int.Parse(dr["vchno"].ToString());
                    video.ip         = dr["vchip"].ToString();
                    video.port       = int.Parse(dr["vchport"].ToString());
                    video.loginName  = dr["loginname"].ToString();
                    video.password   = dr["loginpwd"].ToString();
                    video.parentID   = int.Parse(dr["parentid"].ToString());
                    video.streamType = int.Parse(dr["streamType"].ToString());
                    video.videoName  = dr["vchname"].ToString();
                    video.videoType  = int.Parse(dr["vchtype"].ToString());
                    video.videoAttr  = dr["vchAttr"].ToString();
                    foreach (ClsRecogArea area in Global.recogAreaList)
                    {
                        if (area.videoid == video.id)
                        {
                            video.areaList.Add(area);
                        }
                    }
                    Global.videoList.Add(video);
                    Global.LogServer.Add(new LogInfo("ParamSet-Debug", "Main->GetRecogAreaListFromDB videoid:" +
                                                     video.id.ToString() + "  video.channelNo:" + video.channelNo.ToString(), (int)EnumLogLevel.DEBUG));
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                Global.LogServer.Add(new LogInfo("ParamSet-Error", "Main->InitParam->GetVideoListFromDB 运行初始化失败:" + ex.Message, (int)EnumLogLevel.ERROR));
                return(false);
            }
        }
        private void treeMain_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                TreeNode node = treeMain.SelectedNode;
                if (node.Nodes.Count > 0)
                {
                    return;
                }
                foreach (ClsNVRInfo nvr in Global.nvrList)
                {
                    if (node.Text == nvr.nvrName)
                    {
                        try
                        {
                            if (0 == SPlate.SP_InitNVR(nvr.ip, nvr.port, nvr.loginName, nvr.password))
                            {
                                Global.LogServer.Add(new LogInfo("ParamSet-Debug", "SP_InitNVR true", (int)EnumLogLevel.DEBUG));
                                IntPtr ip    = Marshal.AllocHGlobal(Marshal.SizeOf(nvr.config));
                                int    lenth = 0;
                                SPlate.SP_GetNvrCfg(ip, ref lenth);
                                nvr.config = (NET_DVR_IPPARACFG_V40)Marshal.PtrToStructure(ip, typeof(NET_DVR_IPPARACFG_V40));
                                for (int i = 0; i < nvr.config.dwDChanNum; i++)
                                {
                                    Global.LogServer.Add(new LogInfo("ParamSet-Debug", "dwDChanNum:" + i.ToString(), (int)EnumLogLevel.DEBUG));
                                    if (nvr.config.struIPDevInfo[i].byEnable == 1)
                                    {
                                        ClsVideoChannel videoChan = new ClsVideoChannel();
                                        videoChan.ip         = System.Text.Encoding.Default.GetString(nvr.config.struIPDevInfo[i].struIP.sIpV4);
                                        videoChan.channelNo  = i;
                                        videoChan.loginName  = System.Text.Encoding.Default.GetString(nvr.config.struIPDevInfo[i].sUserName);
                                        videoChan.password   = System.Text.Encoding.Default.GetString(nvr.config.struIPDevInfo[i].sPassword);
                                        videoChan.port       = nvr.config.struIPDevInfo[i].wDVRPort;
                                        videoChan.streamType = nvr.config.struStreamMode[i].byGetStreamType;
                                        videoChan.parentID   = nvr.id;

                                        if (!FindVideoChanInList(videoChan.channelNo, videoChan.ip))
                                        {
                                            videoChan.id = Global.mysqlHelper.ExecuteSql(videoChan.getInsertString());
                                            Global.videoList.Add(videoChan);
                                            nvr.videoList.Add(videoChan);
                                        }

                                        TreeNode cNode = new TreeNode();
                                        cNode.Text = "Video" + i.ToString();
                                        node.Nodes.Add(cNode);

                                        Global.LogServer.Add(new LogInfo("ParamSet-Debug", "struIPDevInfo.byEnable true", (int)EnumLogLevel.DEBUG));
                                    }
                                }
                            }
                            Global.sCurSelectedNvrName = nvr.nvrName;
                            break;
                        }
                        catch (System.Exception ex)
                        {
                            Global.LogServer.Add(new LogInfo("ParamSet-Error", "FormMain->treeMain_DoubleClick", (int)EnumLogLevel.ERROR));
                        }

                        if (Global.nVideoRecogType == 1)
                        {
                            InitHKGroupBoard();
                        }
                    }
                    else
                    {
                        for (int i = 0; i < nvr.config.dwDChanNum; i++)
                        {
                            if (node.Text == "Video" + i.ToString())
                            {
                                NET_DVR_PREVIEWINFO previewInfo = new NET_DVR_PREVIEWINFO();
                                previewInfo.hPlayWnd        = videoBox.Handle; //预览窗口
                                previewInfo.lChannel        = nvr.config.dwStartDChan + i;
                                previewInfo.dwStreamType    = 0;               //码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                                previewInfo.dwLinkMode      = 0;               //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
                                previewInfo.bBlocked        = false;           //0- 非阻塞取流,1- 阻塞取流
                                previewInfo.dwDisplayBufNum = 15;
                                int lenth = Marshal.SizeOf(previewInfo);
                                if (lPlayHandle >= 0)
                                {
                                    SPlate.SP_StopPreview(lPlayHandle);
                                    lPlayHandle = -1;
                                }

                                lPlayHandle = SPlate.SP_PreviewInfo(ref previewInfo, lenth);

                                //更新当前被选中的视频线路
                                Global.bVideoInShow          = true;
                                Global.nCurSelectedVideoChan = i;
                                lblCurVideoNo.Text           = "当前视频:Video" + i.ToString();
                                break;
                            }
                        }

                        SwitchVideo();
                    }
                }
            }
            catch (System.Exception ex)
            {
                Global.LogServer.Add(new LogInfo("ParamSet-Error", "FormMain->treeMain_DoubleClick:" + ex.Message, (int)EnumLogLevel.ERROR));
            }
        }