• 大小: 196KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: 其他
  • 标签: 消息队列  

资源简介

Windows Service 通信 - 消息队列

资源截图

代码片段和文件信息

using System;
using System.IO;

namespace Common
{
    public class Log
    {
        private static object lockWrite = new object();

        public static void Write(Type t Exception e)
        {
            Write(t e null);
        }

        public static void Write(Type t string sLog)
        {
            Write(t null sLog);
        }

        public static void Write(string sLog)
        {
            Write(null null sLog);
        }

        public static void Write(Exception e)
        {
            Write(null e null);
        }

        private static void Write(Type t Exception e string sLog)
        {
            lock (lockWrite)
            {
                string LogDirectory = AppDomain.CurrentDomain.baseDirectory + @“\App_Log\“;

                if (!Directory.Exists(LogDirectory))
                {
                    Directory.CreateDirectory(LogDirectory);
                }

                string LogFile = LogDirectory + DateTime.Now.Date.ToString(“yyyy-MM-dd“) + “.log“;

                string strLog = DateTime.Now.ToString(“yyyy-MM-dd HH:mm:ss“) + “|“;

                if (t != null)
                {
                    strLog += t.FullName;
                }

                if (e != null)
                {
                    strLog += e.Message;
                }

                if (sLog != null)
                {
                    strLog += sLog;
                }

                try
                {
                    StreamWriter writer = new StreamWriter(new FileStream(LogFile FileMode.Append FileAccess.Write) System.Text.Encoding.GetEncoding(“GBK“));
                    writer.WriteLine(strLog);
                    writer.Close();
                }
                catch (SystemException ex)
                {
                    Write(“Log.cs(66)“ + ex.Message);
                }
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       8704  2008-12-18 14:18  WindowsService\Common\bin\Debug\Common.dll

     文件      19968  2008-12-18 14:18  WindowsService\Common\bin\Debug\Common.pdb

     文件       2192  2008-12-17 09:17  WindowsService\Common\Common.csproj

     文件       1970  2008-12-17 09:08  WindowsService\Common\Log.cs

     文件       8995  2008-12-17 13:43  WindowsService\Common\MsSql.cs

     文件        305  2008-12-18 14:18  WindowsService\Common\obj\Debug\Common.csproj.FileListAbsolute.txt

     文件       8704  2008-12-18 14:18  WindowsService\Common\obj\Debug\Common.dll

     文件      19968  2008-12-18 14:18  WindowsService\Common\obj\Debug\Common.pdb

     文件       1354  2008-12-17 09:07  WindowsService\Common\Properties\AssemblyInfo.cs

     文件       8704  2008-12-18 14:18  WindowsService\ServiceDemo\bin\Debug\Common.dll

     文件      19968  2008-12-18 14:18  WindowsService\ServiceDemo\bin\Debug\Common.pdb

     文件       8192  2008-12-18 18:19  WindowsService\ServiceDemo\bin\Debug\ServiceDemo.exe

     文件        942  2008-12-17 11:10  WindowsService\ServiceDemo\bin\Debug\ServiceDemo.InstallLog

     文件      19968  2008-12-18 18:19  WindowsService\ServiceDemo\bin\Debug\ServiceDemo.pdb

     文件      14328  2008-12-18 09:32  WindowsService\ServiceDemo\bin\Debug\ServiceDemo.vshost.exe

     文件        490  2007-07-21 01:33  WindowsService\ServiceDemo\bin\Debug\ServiceDemo.vshost.exe.manifest

     文件       3478  2008-12-18 10:25  WindowsService\ServiceDemo\Installer1.cs

     文件       2178  2008-12-18 10:25  WindowsService\ServiceDemo\Installer1.Designer.cs

     文件       6413  2008-12-18 10:25  WindowsService\ServiceDemo\Installer1.resx

     文件       4096  2008-12-17 08:40  WindowsService\ServiceDemo\obj\Debug\Refactor\ServiceDemo.exe

     文件        651  2008-12-18 17:43  WindowsService\ServiceDemo\obj\Debug\ServiceDemo.csproj.FileListAbsolute.txt

     文件        779  2008-12-18 17:43  WindowsService\ServiceDemo\obj\Debug\ServiceDemo.csproj.GenerateResource.Cache

     文件       8192  2008-12-18 18:19  WindowsService\ServiceDemo\obj\Debug\ServiceDemo.exe

     文件        180  2008-12-18 18:19  WindowsService\ServiceDemo\obj\Debug\ServiceDemo.Installer1.resources

     文件      19968  2008-12-18 18:19  WindowsService\ServiceDemo\obj\Debug\ServiceDemo.pdb

     文件        485  2008-12-16 17:16  WindowsService\ServiceDemo\Program.cs

     文件       1364  2008-12-16 17:16  WindowsService\ServiceDemo\Properties\AssemblyInfo.cs

     文件       2578  2008-12-18 18:11  WindowsService\ServiceDemo\Service1.cs

     文件       1086  2008-12-16 17:16  WindowsService\ServiceDemo\Service1.Designer.cs

     文件       4558  2008-12-18 18:19  WindowsService\ServiceDemo\ServiceDemo.csproj

............此处省略63个文件信息

评论

共有 条评论