Example #1
0
        /// <summary>
        /// 项目扣分
        /// </summary>
        /// <param name="kch">考车号</param>
        /// <param name="xmbh">项目编号,包含项目编号和错误编号,用@分隔</param>
        /// <param name="time">时间</param>
        /// <returns></returns>
        private bool HandleM17C53(int kch, string xmbh, string time)
        {
            string errorMsg = string.Empty;

            string[] strArray = BaseMethod.SplitString(xmbh, BaseDefine.SPLIT_CHAR_AT, out errorMsg);
            if (!string.IsNullOrEmpty(errorMsg) || strArray.Length != 2)
            {
                Log.GetLogger().ErrorFormat("17C53 接口存在错误,{0}", errorMsg);
                return(false);
            }
            string strXmCode     = strArray[0];
            string strErrrorCode = strArray[1];
            int    xmCode        = string.IsNullOrEmpty(strXmCode) ? 0 : int.Parse(strXmCode);

            int kskm = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                 BaseDefine.CONFIG_KEY_KSKM, 0); //考试科目
            string xmName = string.Empty;                                        //项目名称

            if (BaseDefine.CONFIG_VALUE_KSKM_3 == kskm)                          //科目三
            {
                xmName = GetKM3Name(xmCode);
            }
            else  //科目二
            {
                xmName = GetKM2Name(xmCode);
            }

            //扣分类型、扣除分数
            if (!m_dicJudgeRules.ContainsKey(strErrrorCode))
            {
                Log.GetLogger().ErrorFormat("数据库扣分规则表中不存在错误编号为 {0} 的记录,请检查配置。", strErrrorCode);
                return(false);
            }
            string kflx = m_dicJudgeRules[strErrrorCode].JudgementType;
            int    kcfs = m_dicJudgeRules[strErrrorCode].Points;

            if (!m_dicExamProcedures.ContainsKey(kch))
            {
                Log.GetLogger().ErrorFormat("m_dicExamProcedures 字典找不到考车号 : {0}", kch);
                return(false);
            }
            ExamProcedure examProcedure = m_dicExamProcedures[kch];

            if (!examProcedure.Handle17C53(xmName, kflx, kcfs))
            {
                Log.GetLogger().ErrorFormat("examProcedure.Handle17C53 failed, kch={0}", kch);
                return(false);
            }

            Log.GetLogger().InfoFormat("HandleM17C53 end, kch={0}, xmName={1}, kflx={2}, kcfs={3}", kch, xmName, kflx, kcfs);
            return(true);
        }
Example #2
0
        private void QHThreadProc(object obj)
        {
            XmInfo xmInfo = (XmInfo)obj;

            int kch    = xmInfo.Kch;
            int xmCode = xmInfo.XmCode;

            string section   = string.Format("{0}{1}", BaseDefine.CONFIG_SECTION_Q, xmCode);
            int    sleepTime = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ZZIPChannel, section,
                                                         BaseDefine.CONFIG_KEY_TIME, 2000);

            System.Threading.Thread.Sleep(sleepTime);

            HandleM17C52(kch, 1);
        }
Example #3
0
        /// <summary>
        /// 考试完成
        /// </summary>
        /// <param name="kch">考车号</param>
        /// <param name="kscj">考试成绩</param>
        /// <returns></returns>
        private bool HandleM17C56(int kch, int kscj)
        {
            int kshgfs = 0; //考试合格分数

            if (!m_dicExamProcedures.ContainsKey(kch))
            {
                Log.GetLogger().ErrorFormat("HandleM17C56错误,找不到考车 {0}", kch);
                return(false);
            }
            ExamProcedure examPorcedure = m_dicExamProcedures[kch];

            int kskm = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                 BaseDefine.CONFIG_KEY_KSKM, 0); //考试科目

            if (BaseDefine.CONFIG_VALUE_KSKM_3 == kskm)                          //科目三
            {
                kshgfs = BaseDefine.CONFIG_VALUE_KSHGFS_3;
            }
            else  //科目二
            {
                kshgfs = BaseDefine.CONFIG_VALUE_KSHGFS_2;
            }

            bool bPass = (kscj >= kshgfs) ? true : false;

            examPorcedure.Handle17C56(bPass);

            //try
            //{
            //    if (kscj >= kshgfs) //考试合格
            //    {
            //        BaseMethod.TF17C56(kch, 1, kscj);
            //    }
            //}
            //catch (Exception e)
            //{
            //    Log.GetLogger().ErrorFormat("TF17C56 catch an error : {0}, 考车号={1}, 科目{2}, 考试成绩={3}", e.Message,
            //        kch, kskm, kscj);
            //    return false;
            //}

            Log.GetLogger().InfoFormat("TF17C56 end, 考车号={0}, 科目{1}, 考试成绩={2}", kch, kskm, kscj);
            return(true);
        }
Example #4
0
        /// <summary>
        /// 获取考生信息
        /// </summary>
        /// <param name="zkzmbh">准考证明</param>
        /// <param name="arrayZp">身份证照片信息</param>
        /// <param name="arrayMjzp">签到照片信息</param>
        /// <returns></returns>
        private bool GetStudentInfo(string zkzmbh, ref StudentInfo studentInfo)
        {
            //获取考生照片
            Byte[] arrayZp   = null; //照片
            Byte[] arrayMjzp = null; //门禁照片,现场采集
            string sql       = string.Format("select {0},{1} from {2} where {3}='{4}'",
                                             BaseDefine.DB_FIELD_ZP,
                                             BaseDefine.DB_FIELD_MJZP,
                                             BaseDefine.DB_TABLE_STUDENTPHOTO,
                                             BaseDefine.DB_FIELD_ZKZMBH,
                                             zkzmbh);

            Log.GetLogger().DebugFormat("获取考生照片 sql : {0}", sql);
            try
            {
                DataSet ds = m_sqlDataProvider.RetriveDataSet(sql);
                if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows != null)
                {
                    try
                    {
                        arrayZp = (Byte[])ds.Tables[0].Rows[0][0];
                    }
                    catch (Exception e)
                    {
                        Log.GetLogger().InfoFormat("照片获取失败,{0}", e.Message);
                    }

                    try
                    {
                        arrayMjzp = (Byte[])ds.Tables[0].Rows[0][1];
                    }
                    catch (Exception e)
                    {
                        Log.GetLogger().InfoFormat("门禁照片获取失败,{0}", e.Message);
                    }
                }
            }
            catch (Exception e)
            {
                Log.GetLogger().ErrorFormat("查询 StudentPhoto 表发生异常: {0}, zkzmbh={1}, sql = {2}", e.Message, zkzmbh, sql);
                //return false;
            }

            Log.GetLogger().DebugFormat("HQW TEMP");

            //获取考生信息
            string kch      = string.Empty; //考车号
            string bz       = string.Empty; //备注(车牌号)
            string kscx     = string.Empty; //考试车型
            string xingming = string.Empty; //姓名
            string xb       = string.Empty; //性别
            string date     = string.Empty; //日期
            string lsh      = string.Empty; //流水号
            string sfzmbh   = string.Empty; //身份证明编号
            string jxmc     = string.Empty; //驾校名称
            string ksy1     = string.Empty; //考试员1
            string ksyyCode = string.Empty; //考试原因编号
            string ksyyDes  = string.Empty; //考试原因描述
            string drcs     = string.Empty; //当日次数

            string sqlFormat = string.Empty;
            int    dbType    = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                         BaseDefine.CONFIG_KEY_SQLORACLE, 0);

            if (1 == dbType)
            {
                sqlFormat = "select {0},{1}.{2},{3},{4},{5},(Select CONVERT(varchar(100), GETDATE(), 23)) as DATE, {6},{7},{8},{9},{10},{11},{12} from {13} left join {14} on {15}={16} left join {17} on {18}={19} where {20}='{21}'";
            }
            else
            {
                sqlFormat = "select {0},{1}.{2},{3},{4},{5},to_char(sysdate,'yyyy-mm-dd') as MYDATE, {6},{7},{8},{9},{10},{11},{12} from {13} left join {14} on {15}={16} left join {17} on {18}={19} where {20}='{21}'";
            }

            sql = string.Format(
                sqlFormat,
                BaseDefine.DB_FIELD_KCH,
                BaseDefine.DB_TABLE_SYSCFG,
                BaseDefine.DB_FIELD_BZ,
                BaseDefine.DB_FIELD_KSCX,
                BaseDefine.DB_FIELD_XINGMING,
                BaseDefine.DB_FIELD_XB,
                BaseDefine.DB_FIELD_LSH,
                BaseDefine.DB_FIELD_SFZMBH,
                BaseDefine.DB_FIELD_JXMC,
                BaseDefine.DB_FIELD_KSY1,
                BaseDefine.DB_FIELD_KSYY,
                BaseDefine.DB_FIELD_ZKZMBH,
                BaseDefine.DB_FIELD_DRCS,
                BaseDefine.DB_TABLE_STUDENTINFO,
                BaseDefine.DB_TABLE_SCHOOLINFO,
                BaseDefine.DB_FIELD_DLR,
                BaseDefine.DB_FIELD_JXBH,
                BaseDefine.DB_TABLE_SYSCFG,
                BaseDefine.DB_FIELD_KCH,
                BaseDefine.DB_FIELD_XIANGMU,
                BaseDefine.DB_FIELD_ZKZMBH,
                zkzmbh
                );
            Log.GetLogger().DebugFormat("获取考生信息 sql : {0}", sql);
            try
            {
                DataSet ds = m_sqlDataProvider.RetriveDataSet(sql);
                if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows != null)
                {
                    kch      = (null == ds.Tables[0].Rows[0][0]) ? string.Empty : ds.Tables[0].Rows[0][0].ToString();
                    bz       = (null == ds.Tables[0].Rows[0][1]) ? string.Empty : ds.Tables[0].Rows[0][1].ToString();
                    kscx     = (null == ds.Tables[0].Rows[0][2]) ? string.Empty : ds.Tables[0].Rows[0][2].ToString();
                    xingming = (null == ds.Tables[0].Rows[0][3]) ? string.Empty : ds.Tables[0].Rows[0][3].ToString();
                    xb       = (null == ds.Tables[0].Rows[0][4]) ? string.Empty : ds.Tables[0].Rows[0][4].ToString();
                    date     = (null == ds.Tables[0].Rows[0][5]) ? string.Empty : ds.Tables[0].Rows[0][5].ToString();
                    lsh      = (null == ds.Tables[0].Rows[0][6]) ? string.Empty : ds.Tables[0].Rows[0][6].ToString();
                    sfzmbh   = (null == ds.Tables[0].Rows[0][7]) ? string.Empty : ds.Tables[0].Rows[0][7].ToString();
                    jxmc     = (null == ds.Tables[0].Rows[0][8]) ? string.Empty : ds.Tables[0].Rows[0][8].ToString();
                    ksy1     = (null == ds.Tables[0].Rows[0][9]) ? string.Empty : ds.Tables[0].Rows[0][9].ToString();

                    ksyyCode = (null == ds.Tables[0].Rows[0][10]) ? string.Empty : ds.Tables[0].Rows[0][10].ToString();
                    ksyyDes  = getKsyy(ksyyCode);

                    drcs = (null == ds.Tables[0].Rows[0][12]) ? string.Empty : ds.Tables[0].Rows[0][12].ToString();

                    //if (string.IsNullOrEmpty(kch) || string.IsNullOrEmpty(bz) || string.IsNullOrEmpty(kscx) || string.IsNullOrEmpty(xingming)
                    //    || string.IsNullOrEmpty(xb) || string.IsNullOrEmpty(date) || string.IsNullOrEmpty(lsh) || string.IsNullOrEmpty(sfzmbh)
                    //    || string.IsNullOrEmpty(jxmc) || string.IsNullOrEmpty(ksy1))
                    //{
                    //    Log.GetLogger().ErrorFormat("查询 StudentInfo 表值为空,sql={0}", sql);
                    //    return false;
                    //}

                    Log.GetLogger().DebugFormat("kch={0}, bz={1}, kscx={2}, xingming={3},xb={4},date={5},lsh={6},sfzmbh={7},jxmc={8},ksy1={9}, ksyyCode={10}, ksyyDes={11}, drcs={12}",
                                                kch, bz, kscx, xingming, xb, date, lsh, sfzmbh, jxmc, ksy1, ksyyCode, ksyyDes, drcs);
                }
            }
            catch (Exception e)
            {
                Log.GetLogger().ErrorFormat("查询 StudentInfo 表发生异常: {0}, zkzmbh={1}", e.Message, zkzmbh);
                return(false);
            }

            studentInfo = new StudentInfo(kch, bz, kscx, xingming, xb, date, lsh, sfzmbh, jxmc, ksy1, ksyyDes, drcs, arrayZp, arrayMjzp);

            Log.GetLogger().DebugFormat("GetStudentInfo success, zkzmbh={0}", zkzmbh);
            return(true);
        }
Example #5
0
        /// <summary>
        /// 项目完成
        /// </summary>
        /// <param name="kch">考车号</param>
        /// <param name="strZkzmbh">准考证明</param>
        /// <param name="strXmbh">项目编号</param>
        /// <returns></returns>
        private bool HandleM17C55(int kch, string strZkzmbh, string strXmbh)
        {
            //项目开始编号与项目完成编号不一样,车载没有把完成编号传过来,这里需要根据开始编号进行转换
            int xmBeginCode = string.IsNullOrEmpty(strXmbh) ? 0 : int.Parse(strXmbh);
            int xmEndCode   = 0;

            int kskm = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                 BaseDefine.CONFIG_KEY_KSKM, 0); //考试科目

            if (BaseDefine.CONFIG_VALUE_KSKM_3 == kskm)                          //科目三
            {
                string key = string.Format("考车{0}_2", kch);
                if (!m_dicCameras.ContainsKey(key))
                {
                    Log.GetLogger().ErrorFormat("找不到 {0} 摄像头配置,请检查配置", key);
                    //return false;
                }
                else
                {
                    CameraConf camera = m_dicCameras[key];
                    m_dicCars[kch].StartDynamicDecode(camera, 1);   //车载视频动态,第二画面车外
                }

                //科目三的项目完成编号为,开始编号+700
                //218 --> 918
                if (xmBeginCode < BaseDefine.XMBH_700)
                {
                    xmEndCode = xmBeginCode + BaseDefine.XMBH_700;
                }
                else
                {
                    xmEndCode = xmBeginCode;
                }
            }
            else  //科目二
            {
                //项目编号转换,科目二专用,数据库升级后可以不需要这段代码
                xmBeginCode = GetKM2NewXmBh(xmBeginCode);

                //e.g. 201500 --> 201990
                // 201500 先除以 1000,得到 201。再乘以 1000,得到 201000。再加上 990,得到 201990。
                xmEndCode = (xmBeginCode / 1000) * 1000 + 990;

                //科目二切换到场地远景视频
                string key = BaseDefine.STRING_KM2_PUBLIC_VIDEO;
                if (!m_dicCameras.ContainsKey(key))
                {
                    Log.GetLogger().ErrorFormat("找不到 {0} 摄像头配置,请检查配置", key);
                    //return false;
                }
                else
                {
                    CameraConf camera = m_dicCameras[key];
                    m_dicCars[kch].StartDynamicDecode(camera, 1);
                }
            }

            //获取项目类型
            if (!m_dicJudgeRules.ContainsKey(xmEndCode.ToString()))
            {
                Log.GetLogger().ErrorFormat("ErrorData 表不存在 {0} 记录,请检查配置", xmEndCode);
                return(false);
            }
            string xmlx = m_dicJudgeRules[xmEndCode.ToString()].JudgementType;

            if (!m_dicExamProcedures.ContainsKey(kch))
            {
                Log.GetLogger().ErrorFormat("m_dicExamProcedures 字典找不到考车号 : {0}", kch);
                return(false);
            }
            ExamProcedure examProcedure = m_dicExamProcedures[kch];

            if (!examProcedure.Handle17C55(xmBeginCode, xmlx))
            {
                Log.GetLogger().ErrorFormat("examProcedure.Handle17C55 failed, kch={0}", kch);
                return(false);
            }

            return(true);
        }
Example #6
0
        /// <summary>
        /// 项目开始
        /// </summary>
        /// <param name="kch">考车号</param>
        /// <param name="zkzmbh">准考证明编号</param>
        /// <param name="xmbh">项目编号</param>
        /// <returns></returns>
        private bool HandleM17C52(int kch, string zkzmbh, string xmbh)
        {
            int xmCode = string.IsNullOrEmpty(xmbh) ? 0 : int.Parse(xmbh);
            int nWnd2  = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_DISPLAY, BaseDefine.CONFIG_SECTION_CONFIG,
                                                   BaseDefine.CONFIG_KEY_WND2, 1); //画面二状态

            Log.GetLogger().DebugFormat("nWnd2 = {0}", nWnd2);

            if (1 == nWnd2)     //值为1时进行项目动态切换
            {
                string key = string.Format("{0}_1", xmbh);
                Log.GetLogger().DebugFormat("camera key = {0}", key);
                if (!m_dicCameras.ContainsKey(key))
                {
                    Log.GetLogger().ErrorFormat("摄像头 {0} 未配置,请检查配置文件。", key);
                    return(false);
                }

                CameraConf camera = m_dicCameras[key];
                m_dicCars[kch].StartDynamicDecode(camera, 1);   //第二画面进项目

                ////处理定点
                ////半坡停车时,车载会发 15010 摄像头编号过来,切换摄像头后,另外开一个线程,休眠几秒时间后,切换为原来的摄像头
                //if ((BaseDefine.XMBH_15010 == xmCode) || (BaseDefine.XMBH_15020 == xmCode) || (BaseDefine.XMBH_15030 == xmCode))
                //{
                //    Log.GetLogger().InfoFormat("定点:{0}", xmCode);

                //    if (BaseMethod.IsExistFile(BaseDefine.CONFIG_FILE_PATH_ZZIPChannel))
                //    {
                //        XmInfo xmInfo = new XmInfo(kch, xmCode);

                //        Thread QHThread = new Thread(new ParameterizedThreadStart(QHThreadProc));
                //        QHThread.Start(xmInfo);
                //    }

                //    return true;
                //}
            }

            //项目编号转换,科目二专用,数据库升级后可以不需要这段代码
            int xmCodeNew = GetKM2NewXmBh(xmCode);

            Log.GetLogger().DebugFormat("xmCodeNew = {0}", xmCodeNew);

            //获取项目类型(因为数据库里扣分类型和项目类型存在同一张表,所以这里参考C++代码,全部存在同一张字典里)
            if (!m_dicJudgeRules.ContainsKey(xmbh))
            {
                Log.GetLogger().ErrorFormat("扣分类型 {0} 未配置,请检查配置", xmbh);
                return(false);
            }
            string xmlx = m_dicJudgeRules[xmbh].JudgementType;  //项目类型

            if (!m_dicExamProcedures.ContainsKey(kch))
            {
                Log.GetLogger().ErrorFormat("m_dicExamProcedures 字典找不到考车号 : {0}", kch);
                return(false);
            }
            ExamProcedure examProcedure = m_dicExamProcedures[kch];

            if (!examProcedure.Handle17C52(xmCodeNew, xmlx))
            {
                Log.GetLogger().ErrorFormat("examProcedure.Handle17C52 failed, kch={0}", kch);
                return(false);
            }

            //try
            //{
            //    //使用 C++ dll 进行绘制
            //    Log.GetLogger().DebugFormat("kch={0}, zkzmbh={1}, xmCode={2}, kflx={3}", kch, zkzmbh, xmCodeNew, kflx);
            //    BaseMethod.TF17C52(kch, zkzmbh, xmCodeNew, kflx);
            //}
            //catch (Exception e)
            //{
            //    Log.GetLogger().ErrorFormat("TF17C52 catch an error : {0}, kch = {1}, zkzmbh = {2}, xmCodeNew = {3}, kflx = {4}",
            //        e.Message, kch, zkzmbh, xmCodeNew, kflx);
            //    return false;
            //}

            Log.GetLogger().InfoFormat("HandleM17C52 end, kch={0}, zkzmbh={1}", kch, zkzmbh);
            return(true);
        }
Example #7
0
        //开始运行
        private bool RunMap()
        {
            string     key        = string.Empty;
            CameraConf cameraConf = new CameraConf();

            //地图
            Image imgMap   = null;
            int   nLoadMap = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                       BaseDefine.CONFIG_KEY_LOADMAP, 0);

            if (1 == nLoadMap)
            {
                try
                {
                    imgMap = Image.FromFile(BaseDefine.IMG_PATH_MAPN);
                }
                catch (Exception e)
                {
                    Log.GetLogger().ErrorFormat("Image.FromFile catch an error : {0}", e.Message);
                }
            }

            foreach (int iKch in dicCars.Keys)
            {
                Thread.Sleep(10);

                CarManager carManager = dicCars[iKch];

                //动态解码
                key = string.Format("考车{0}_1", iKch);
                if (!dicCameras.ContainsKey(key))
                {
                    Log.GetLogger().ErrorFormat("{0} 摄像头未配置,请检查", key);
                }
                else
                {
                    cameraConf = dicCameras[key];
                    carManager.StartDynamicDecode(cameraConf, 0);
                }

                key = string.Format("考车{0}_2", iKch);
                if (!dicCameras.ContainsKey(key))
                {
                    Log.GetLogger().ErrorFormat("{0} 摄像头未配置,请检查", key);
                }
                else
                {
                    cameraConf = dicCameras[key];
                    carManager.StartDynamicDecode(cameraConf, 1);
                }

                try
                {
                    //被动解码
                    int thirdPH  = -1;
                    int fourthPH = -1;
                    if (carManager.StartPassiveDecode(2, ref thirdPH) && carManager.StartPassiveDecode(3, ref fourthPH))
                    {
                        ExamProcedure examProcedure = new ExamProcedure();
                        if (examProcedure.Init(m_userId, iKch, thirdPH, fourthPH, imgMap))
                        {
                            dicExamProcedures.Add(iKch, examProcedure);
                        }
                    }
                    else
                    {
                        Log.GetLogger().ErrorFormat("被动解码失败,kch={0}", iKch);
                    }
                }
                catch (Exception e)
                {
                    Log.GetLogger().ErrorFormat("catch an error : {0}", e.Message);
                }
            }

            return(true);
        }
Example #8
0
        private bool InitDevices()
        {
            dicCars.Clear();

            //获取 SDK Build
            if (!GetSDKBuildVersion())
            {
                return(false);
            }

            //窗口初始化(看不懂是什么作用,这里先翻译C++代码)
            int    kch   = 0;
            int    count = 4;
            string key   = string.Empty;

            m_dispalyShow[4] = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_DISPLAY, BaseDefine.CONFIG_SECTION_CONFIG,
                                                         BaseDefine.CONFIG_KEY_VIDEOWND, 1);
            for (int i = 0; i < count; i++)
            {
                key = string.Format("{0}{1}", BaseDefine.CONFIG_KEY_DISPLAY, i + 1);
                m_dispalyShow[i] = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_DISPLAY, BaseDefine.CONFIG_SECTION_CONFIG,
                                                             key, i);
                kch += m_dispalyShow[i];
            }
            if (kch != 6)
            {
                for (int i = 0; i < count; i++)
                {
                    key = string.Format("{0}{1}", BaseDefine.CONFIG_KEY_DISPLAY, i + 1);
                    string value = i.ToString();
                    INIOperator.INIWriteValue(BaseDefine.CONFIG_FILE_PATH_DISPLAY, BaseDefine.CONFIG_SECTION_CONFIG, key, value);
                    m_dispalyShow[i] = i;
                }
            }
            Log.GetLogger().InfoFormat("子窗口配置[%d,%d,%d,%d],音频窗口[%d]", m_dispalyShow[0], m_dispalyShow[1],
                                       m_dispalyShow[2], m_dispalyShow[3], m_dispalyShow[4]);

            //合码器初始化
            int nNum = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_CAR, BaseDefine.CONFIG_SECTION_JMQ,
                                                 BaseDefine.CONFIG_KEY_NUM, 0);   //合码器数量
            int nEven = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_DISPLAY, BaseDefine.CONFIG_SECTION_CONFIG,
                                                  BaseDefine.CONFIG_KEY_EVEN, 0); //是否隔行合码
            int nKskm = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                  BaseDefine.CONFIG_KEY_KSKM, 0); //考试科目
            int nWnd2 = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_DISPLAY, BaseDefine.CONFIG_SECTION_CONFIG,
                                                  BaseDefine.CONFIG_KEY_WND2, 1); //画面二状态
            int nHMQ = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                 BaseDefine.CONFIG_KEY_HMQ, 0);   //配置的是合码器还是解码器

            if (0 == nNum)
            {
                Log.GetLogger().ErrorFormat("合码器数量为0,请检查配置文件");
                return(false);
            }
            Log.GetLogger().InfoFormat("读取到 {0} 台合码器,EVEN = {1}, 科目{2},画面2={3}", nNum, nEven, nKskm, nWnd2);

            string errorMsg = string.Empty;

            for (int i = 1; i <= nNum; i++)
            {
                string strConf = INIOperator.INIGetStringValue(BaseDefine.CONFIG_FILE_PATH_CAR, BaseDefine.CONFIG_SECTION_JMQ,
                                                               i.ToString(), string.Empty);
                string[] confArray = BaseMethod.SplitString(strConf, BaseDefine.SPLIT_CHAR_COMMA, out errorMsg);
                if (!string.IsNullOrEmpty(errorMsg) || confArray.Length != 4)
                {
                    Log.GetLogger().ErrorFormat("合码器配置错误,请检查配置文件。section = {0}, key = {1}", BaseDefine.CONFIG_SECTION_JMQ, i.ToString());
                    return(false);
                }

                string ipAddress = confArray[0]; //合码器地址
                string user      = confArray[1]; //用户名
                string password  = confArray[2]; //密码
                string port      = confArray[3]; //端口
                if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(port))
                {
                    Log.GetLogger().ErrorFormat("合码器配置错误,请检查配置文件。section = {0}, key = {1}", BaseDefine.CONFIG_SECTION_JMQ, i.ToString());
                    return(false);
                }
                Log.GetLogger().InfoFormat("准备对合码器 {0} 进行初始化,ip={1}, port={2}, user={3}, password={4}", i, ipAddress, port, user, password);

                //登录设备
                if (!InitHMQ(ipAddress, user, password, port))
                {
                    return(false);
                }

                int    displayChanCount = (1 == nHMQ) ? m_struDecAbility.struDviInfo.byChanNums : m_struDecAbility.struBncInfo.byChanNums;
                string sectionJMQ       = string.Format("JMQ{0}", i);
                for (int j = 0; j < displayChanCount; j++)   //DVI、BNC 个数循环
                {
                    if ((1 == nEven) && (j % 2 == 1))
                    {
                        continue;
                    }

                    string keyBNC = string.Format("BNC{0}", j + 1); //从 1 开始
                    int    nKch   = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_CAR, sectionJMQ, keyBNC, -1);
                    if (-1 == nKch)                                 //没有配置
                    {
                        Log.GetLogger().InfoFormat("合码器 JMQ{0} 的 BNC 通道 {1} 处于空闲,可以配置。", i, keyBNC);
                        continue;
                    }

                    //检查通道配置及初始化
                    if (1 == nHMQ)
                    {
                        if (!CheckDVIChan(nKch, j)) //合码器
                        {
                            Log.GetLogger().ErrorFormat("通道检测及初始化错误,考车号={0},DVI={1}", nKch, j);
                        }
                    }
                    else
                    {
                        if (!CheckBNCChan(nKch, j)) //解码器
                        {
                            Log.GetLogger().ErrorFormat("通道检测及初始化错误,考车号={0},BNC={1}", nKch, j);
                        }
                    }
                }
            }

            return(true);
        }
Example #9
0
        /// <summary>
        /// 读取配置文件里的数据库连接字符串
        /// 配置文件config.ini里的数据库连接字符串加过盐,这里解析时需要将每个字符“-1”后,再进行翻转
        /// </summary>
        /// <returns></returns>
        private string GetConnectionString()
        {
            string retConnectionStr = string.Empty;

            //try
            //{
            //    string configStr = INIOperator.INIGetStringValue(BaseDefine.CONFIG_FILE_PATH_CONFIG, BaseDefine.CONFIG_SECTION_SQLLINK,
            //        BaseDefine.CONFIG_KEY_ServerPZ, string.Empty);
            //    if (!string.IsNullOrEmpty(configStr))
            //    {
            //        foreach (char c in configStr.ToCharArray())
            //        {
            //            int nC = (int)c;
            //            retConnectionStr = (char)(nC - 1) + retConnectionStr;
            //        }
            //    }
            //}
            //catch(Exception e)
            //{
            //    Log.GetLogger().ErrorFormat("catch an error : {0}", e.Message);
            //}
            //Log.GetLogger().InfoFormat("connection string after decode : {0}", retConnectionStr);
            ////配置文件里的数据库连接字符串包含"Provider=SQLOLEDB;",这在C#代码中不适用,这里去除该字段
            //if (0 == retConnectionStr.IndexOf("Provider=SQLOLEDB;"))
            //{
            //    retConnectionStr = retConnectionStr.Substring(18);
            //}
            //Log.GetLogger().InfoFormat("connection string after delete : {0}", retConnectionStr);

            try
            {
                string encodeAddress = INIOperator.INIGetStringValue(BaseDefine.CONFIG_FILE_PATH_DB,
                                                                     BaseDefine.CONFIG_SECTION_CONFIG, BaseDefine.CONFIG_KEY_DBADDRESS, "");
                string encodeUsername = INIOperator.INIGetStringValue(BaseDefine.CONFIG_FILE_PATH_DB,
                                                                      BaseDefine.CONFIG_SECTION_CONFIG, BaseDefine.CONFIG_KEY_USERNAME, "");
                string encodePassword = INIOperator.INIGetStringValue(BaseDefine.CONFIG_FILE_PATH_DB,
                                                                      BaseDefine.CONFIG_SECTION_CONFIG, BaseDefine.CONFIG_KEY_PASSWORD, "");
                string encodeInstance = INIOperator.INIGetStringValue(BaseDefine.CONFIG_FILE_PATH_DB,
                                                                      BaseDefine.CONFIG_SECTION_CONFIG, BaseDefine.CONFIG_KEY_INSTANCE, "");
                if (string.IsNullOrEmpty(encodeAddress) || string.IsNullOrEmpty(encodeUsername) || string.IsNullOrEmpty(encodePassword) ||
                    string.IsNullOrEmpty(encodeInstance))
                {
                    Log.GetLogger().ErrorFormat("数据库配置存在异常");
                    return(retConnectionStr);
                }

                string dbAddress  = BekUtils.Util.Base64Util.Base64Decode(encodeAddress);
                string dbUsername = BekUtils.Util.Base64Util.Base64Decode(encodeUsername);
                string dbPassword = BekUtils.Util.Base64Util.Base64Decode(encodePassword);
                string dbInstance = BekUtils.Util.Base64Util.Base64Decode(encodeInstance);
                if (string.IsNullOrEmpty(dbAddress) || string.IsNullOrEmpty(dbUsername) || string.IsNullOrEmpty(dbPassword) ||
                    string.IsNullOrEmpty(dbInstance))
                {
                    Log.GetLogger().ErrorFormat("数据库配置存在异常");
                    return(retConnectionStr);
                }

                int dbType = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG,
                                                       BaseDefine.CONFIG_KEY_SQLORACLE, 0);
                if (1 == dbType)
                {
                    //SQL
                    retConnectionStr = string.Format(BaseDefine.DB_CONN_FORMAT_SQL, dbAddress, dbInstance, dbUsername, dbPassword);
                }
                else
                {
                    //ORACLE
                    retConnectionStr = string.Format(BaseDefine.DB_CONN_FORMAT_ORACLE, dbUsername, dbPassword, dbAddress, dbInstance);
                }
            }
            catch (Exception e)
            {
                Log.GetLogger().ErrorFormat("catch an error : {0}", e.Message);
            }

            return(retConnectionStr);
        }