Ejemplo n.º 1
0
        private void login_Load(object sender, EventArgs e)
        {
            string strConfigPath = AppDomain.CurrentDomain.BaseDirectory + "config.ini";

            if (!File.Exists(strConfigPath))
            {
                FileStream fs = new FileStream(strConfigPath, FileMode.OpenOrCreate);
            }
            StaticData.g_strServerIP       = OperateIniFile.ReadIniData("Login", "server", null, strConfigPath);
            StaticData.g_strDBname         = OperateIniFile.ReadIniData("Login", "database", null, strConfigPath);
            StaticData.g_strDBport         = OperateIniFile.ReadIniData("Login", "port", null, strConfigPath);
            StaticData.g_strDBUserName     = OperateIniFile.ReadIniData("Login", "uid", null, strConfigPath);
            StaticData.g_strDBUserPassword = OperateIniFile.ReadIniData("Login", "password", null, strConfigPath);


            //从自己的数据库中读取用户登录信息
            DBConnect getSystemArgvDBC = new DBConnect();

            try
            {
                if (getSystemArgvDBC.msConn.State == System.Data.ConnectionState.Closed)
                {
                    getSystemArgvDBC.msConn.Open();
                }
                string          strCMD    = "select *  from config_support_platform;";
                MySqlCommand    cmd       = new MySqlCommand(strCMD, getSystemArgvDBC.msConn);
                MySqlDataReader sqlReader = cmd.ExecuteReader();
                while (sqlReader.Read())
                {
                    //根据配置名称,将数据库中取到的数据存入全局变量。
                    switch (sqlReader["config_type"].ToString())
                    {
                    case "user":
                        m_strUser     = sqlReader["username"].ToString();
                        m_strPassword = sqlReader["password"].ToString();
                        break;
                    }
                }
                sqlReader.Close();
                getSystemArgvDBC.msConn.Close();
                getSystemArgvDBC.msConn = null;
            }
            catch (Exception eexx)
            {
                MessageBox.Show(DateTime.Now.ToString() + "  login.class-login_Load :数据库检索失败,请检查配置文件");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据数据库对海康摄像头进行遍历
        /// </summary>
        public void InitHKCamera()
        {
            StaticData.g_dtCamera.Columns.Add("序号", typeof(int));
            StaticData.g_dtCamera.Columns.Add("编号", typeof(string));
            StaticData.g_dtCamera.Columns.Add("摄像头名称", typeof(string));
            StaticData.g_dtCamera.Columns.Add("摄像头状态", typeof(string));
            StaticData.g_dtCamera.Columns.Add("IP地址", typeof(string));
            StaticData.g_dtCamera.Columns.Add("用户名", typeof(string));
            StaticData.g_dtCamera.Columns.Add("密码", typeof(string));
            StaticData.g_dtCamera.Columns.Add("端口", typeof(int));
            StaticData.g_dtCamera.Columns.Add("NVRIP地址", typeof(string));
            StaticData.g_dtCamera.Columns.Add("通道号", typeof(string));
            StaticData.g_dtCamera.Columns.Add("RTSP地址", typeof(string));
            StaticData.g_dtCamera.Columns.Add("转码标识", typeof(int));
            StaticData.g_dtCamera.Columns.Add("theone", typeof(string));
            StaticData.g_dtCamera.Columns.Add("坐标", typeof(string));
            StaticData.g_dtCamera.Columns.Add("RTMP地址", typeof(string));
            StaticData.g_dtCamera.Columns.Add("HLS地址", typeof(string));
            StaticData.g_dtCamera.Columns.Add("摄像头型号", typeof(string));
            StaticData.g_dtCamera.Columns.Add("摄像头型类型", typeof(string));
            StaticData.g_dtCamera.Columns.Add("摄像头型区域", typeof(string));
            StaticData.g_dtCamera.Columns.Add("流ID", typeof(string));
            //下面是转码配置,先不管
            string strConfigPath = AppDomain.CurrentDomain.BaseDirectory + "config.ini";

            m_hlsPort = OperateIniFile.ReadIniData("Login", "hlsPort", null, strConfigPath);//读取hls流使用的端口号

            /*--------------------------------------------------------------------------------
             *  读取camera表,获取IP、名称、channel、line等
             *  进行摄像头状态获取及流转换处理
             *  之后更新Form中的数据
             *  ---------------------------------------------------------------------------------*/
            DBConnect getCameraDBC = new DBConnect();

            try
            {
                if (getCameraDBC.msConn.State == System.Data.ConnectionState.Closed)
                {
                    getCameraDBC.msConn.Open();
                }
                string          strCMD            = "select device_paper_number,device_name,device_ip,device_type,device_area,device_nvrip,device_channel,device_theone,concat_ws(',',ST_X(device_point),ST_Y(device_point),device_height) as device_position,device_rtsp,device_transcoding_flag from device_camera;";
                MySqlCommand    cmd               = new MySqlCommand(strCMD, getCameraDBC.msConn);
                MySqlDataReader sqlReaderCamera   = null;
                string          currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                if (StaticUtils.DBReaderOperationException(ref cmd, ref sqlReaderCamera, currentClassName, currentMethodName))
                {
                    int i = 0;
                    while (sqlReaderCamera.Read())
                    {
                        DataRow dr = StaticData.g_dtCamera.NewRow();//表格的行
                        dr["序号"]      = i;
                        dr["编号"]      = sqlReaderCamera["device_paper_number"].ToString();
                        dr["摄像头名称"]   = sqlReaderCamera["device_name"].ToString();
                        dr["IP地址"]    = sqlReaderCamera["device_ip"].ToString();
                        dr["摄像头型类型"]  = sqlReaderCamera["device_type"].ToString();
                        dr["摄像头型区域"]  = sqlReaderCamera["device_area"].ToString();
                        dr["NVRIP地址"] = sqlReaderCamera["device_nvrip"].ToString();
                        dr["通道号"]     = sqlReaderCamera["device_channel"].ToString();
                        dr["theone"]  = sqlReaderCamera["device_theone"].ToString();
                        dr["坐标"]      = sqlReaderCamera["device_position"].ToString();
                        dr["RTSP地址"]  = sqlReaderCamera["device_rtsp"].ToString();

                        // 针对转码标识为空无法直转int 作条件判断
                        if (sqlReaderCamera["device_transcoding_flag"] is System.DBNull || "".Equals(sqlReaderCamera["device_transcoding_flag"]))
                        {
                            dr["转码标识"] = 0;
                        }
                        else
                        {
                            dr["转码标识"] = Convert.ToInt32(sqlReaderCamera["device_transcoding_flag"]);
                        }

                        dr["IP地址"] = sqlReaderCamera["device_ip"].ToString();
                        dr["用户名"]  = "admin";
                        dr["密码"]   = "admin123456";
                        dr["端口"]   = 8000;
                        StaticData.g_dtCamera.Rows.Add(dr);//添加
                        i++;
                    }


                    //读取完所有摄像头后,遍历一遍状态
                    //遍历一遍NVR,将NVR中各个通道的状态与摄像头列表进行管线,进行整体状态维护,其中根据NVRIP 与通道号进行关联
                    for (int k = 0; k < StaticData.g_dtNVR.Rows.Count; k++)
                    {
                        Hikvision hikivisionList = new HikIPListFun();
                        hikivisionList.IPListFun(Convert.ToInt32(StaticData.g_dtNVR.Rows[k]["userid"]));  //调用IPList方法,将状态写入到dicIPList字典中
                    }

                    sqlReaderCamera.Close();
                }
                getCameraDBC.msConn.Close();
                getCameraDBC.msConn = null;
            }
            catch
            {
                StaticUtils.ShowEventMsg("HikvisionAlarmCallBackFun.class-InitHKCamera : 利用DB初始化摄像头出现异常!!\n");
            }
        }