コード例 #1
0
        private static string createFile(string process, TimeSpan time)
        {
            clsDatabase d = new clsDatabase();
            string      filename;

            if (Properties.Settings.Default.FilePath.Length > 0)
            {
                filename = Properties.Settings.Default.FilePath;
            }
            else
            {
                filename = Path.GetFullPath(Application.ExecutablePath);
            }

            if (!filename.EndsWith("\\") || !filename.EndsWith("/"))
            {
                filename = filename + "\\";
            }
            filename = filename + process + DateTime.Now.ToString("MM-dd-yy_hhmmss") + ".txt";


            clearOldLogs(process, filename);
            StreamWriter sw = new StreamWriter(filename);

            foreach (ProcessLogs pl in d.printLogs(process, time))
            {
                sw.WriteLine(string.Format("{0} ({1}) {2}.{3}\t {4}", pl.LogDate, pl.LogCode.Trim(), pl.ProcessName, pl.ProcessPhase, pl.LogMessage));
            }
            sw.Close();
            return(Path.GetFullPath(filename));
        }
コード例 #2
0
ファイル: DBLogging.cs プロジェクト: muguangyuze/USGS-NIDIS
        public static void WriteLog(string process, string code, string function, string message)
        {
            clsDatabase l = new clsDatabase();

            l.WriteLogDB(process, code, function, message);
        }