Пример #1
0
        /// <summary>
        /// 根据返回码取返回信息
        /// </summary>
        /// <param name="retcode">返回码</param>
        /// <returns>返回信息</returns>
        public static string GetRetMsg(string retcode)
        {
            string   strTmp = "";
            INIClass inicls = new INIClass(Service_NCSB.MyConfigFile);

            if (!inicls.ExistINIFile())
            {
                return("未知错误");
            }
            strTmp = inicls.IniReadValue("RETCODE", retcode);
            if (strTmp == "")
            {
                strTmp = "未知错误码";
            }
            return(strTmp);
        }
Пример #2
0
        /// <summary>
        /// 程序初始化
        /// </summary>
        /// <returns></returns>
        private static bool init()
        {
            string strTmp;

            MyPath       = System.Environment.CurrentDirectory;
            MyPath       = System.IO.Directory.GetCurrentDirectory();
            MyPath       = System.AppDomain.CurrentDomain.BaseDirectory;
            MyConfigFile = MyPath + "Config.ini";
            log.WriteEntry(MyConfigFile, EventLogEntryType.Information);
            MyIni = new INIClass(MyConfigFile);

            if (!MyIni.ExistINIFile())
            {
                log.WriteEntry("Config.ini文件不存在", EventLogEntryType.Information);
                return(false);
            }
            strTmp  = MyIni.IniReadValue("SYSTEM", "LOG");
            logDate = DateTime.Now.ToString("yyyyMMdd");
            if (strTmp != "")
            {
                logName = strTmp;
            }
            else
            {
                logName = "LWS";
            }
            strLogFile = Service_NCSB.MyPath + "\\" + logName + "." + logDate + ".log";
            //if (!File.Exists(strLogFile))
            //{
            //    File.Create(strLogFile);
            //}
            myFs = new FileStream(strLogFile, FileMode.OpenOrCreate | FileMode.Append);
            sw   = new StreamWriter(myFs);
            WriteLog("WriteLog start...");
            strTmp = MyIni.IniReadValue("SYSTEM", "Port");
            try
            {
                iPort = int.Parse(strTmp.Trim());
            }
            catch (Exception)
            {
                log.WriteEntry("端口配置错误!", EventLogEntryType.Information);
                WriteLog("端口配置错误!");
                return(false);
            }

            strTmp = MyIni.IniReadValue("Comm", "SendLen");
            try
            {
                iSendLen = int.Parse(strTmp.Trim());
            }
            catch (Exception)
            {
                iSendLen = 0;
            }
            strTmp = MyIni.IniReadValue("Comm", "RecvLen");
            try
            {
                iRecvLen = int.Parse(strTmp.Trim());
            }
            catch (Exception)
            {
                iRecvLen = 0;
            }

            return(true);
        }