Beispiel #1
0
        public static void WriteLog_Err(string LogStr, int type, string fileName)
        {
            string strType = "Info";

            StreamWriter sw = null;

            try
            {
                // 读取log文件的路径
                string log_dir = G_INI.ReadValue(IniInfo.Log, IniInfo.Log_dir);
                if (!log_dir.EndsWith("\\"))
                {
                    log_dir = log_dir + "\\";
                }
                FileOperte.PathIsExsit(log_dir);
                string file    = fileName + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log";
                string logFile = log_dir + file;
                FileOperte.FileIsExsit(logFile);

                // 类型
                switch (type)
                {
                case LogTypeInfo:
                    strType = "Info:";
                    break;

                case LogTypeErr:
                    strType = "Error:";
                    break;

                default:
                    strType = "Info:";
                    break;
                }
                LogStr = DateTime.Now.ToLocalTime().ToString() + " 【" + strType + " 】" + LogStr;
                sw     = new StreamWriter(logFile, true, Encoding.Unicode);
                sw.WriteLine(LogStr);
            }
            catch (Exception)
            {
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
Beispiel #2
0
        public static string GetLogFileName()
        {
            // 读取log文件的路径
            string log_dir = G_INI.ReadValue(IniInfo.Log, IniInfo.Log_dir);

            if (!log_dir.EndsWith("\\"))
            {
                log_dir = log_dir + "\\";
            }
            FileOperte.PathIsExsit(log_dir);
            string file    = DateTime.Now.ToString("yyyyMMdd") + ".log";
            string logFile = log_dir + file;

            return(logFile);
        }
Beispiel #3
0
        /// <summary>
        /// 从ini文件读取数据库连接字符串
        /// </summary>
        /// <returns></returns>
        public static string GetConnString()
        {
            string connStr  = "";
            string server   = "";
            string uid      = "";
            string pwd      = "";
            string database = "";

            // 读取ini文件
            // 服务器
            server = G_INI.ReadValue("db", "server");
            // 用户名
            uid = G_INI.ReadValue("db", "uid");
            // 密码
            pwd = G_INI.ReadValue("db", "pwd");
            // 数据库
            database = G_INI.ReadValue("db", "database");
            connStr  = "server=" + server + ";uid=" + uid + ";pwd=" + pwd + ";database=" + database;
            return(connStr);
        }