示例#1
0
        public static void WriteSNLog(string type, string headAddress, string segment, string sn, byte[] data)
        {
            DateTime d        = DateTime.Now;
            string   filePath = "";
            string   fileName = "";

            filePath = string.Format("log\\SN\\{0}-{1}\\{2}\\{3}", segment, headAddress, d.ToString("yyyy"), d.ToString("yyyy-MM"));
            fileName = d.ToString("yyyy-MM-dd HH") + " .txt";
            try
            {
                Directory.CreateDirectory(filePath);
                StreamWriter sw = new StreamWriter(filePath + "\\" + fileName, true, Encoding.GetEncoding("gb2312"));
                sw.WriteLine("接收时间:" + d.ToString());
                sw.WriteLine("类别:" + type);
                sw.WriteLine("流水号:" + sn);
                if (data != null)
                {
                    sw.WriteLine("原始数据:" + PubLib.BytesToString(data));
                }
                sw.WriteLine();
                sw.Flush();
                sw.Close();
            }
            catch { }
        }
示例#2
0
        public static void WriteLog(Exception ex, byte[] data)
        {
            DateTime d        = DateTime.Now;
            string   filePath = "";
            string   fileName = "";

            filePath = string.Format("log\\{0}\\{1}", d.ToString("yyyy"), d.ToString("yyyy-MM"));
            fileName = d.ToString("yyyy-MM-dd") + ".txt";
            try
            {
                Directory.CreateDirectory(filePath);
                StreamWriter sw = new StreamWriter(filePath + "\\" + fileName, true, Encoding.GetEncoding("gb2312"));
                sw.WriteLine("错误时间:" + d.ToString());
                sw.WriteLine("错误内容:" + ex.Message);
                if (data != null)
                {
                    sw.WriteLine("数据包内容:" + PubLib.BytesToString(data));
                }
                sw.WriteLine("堆栈信息:" + ex.StackTrace);
                sw.WriteLine();
                sw.Flush();
                sw.Close();
            }
            catch { }
        }
示例#3
0
        public static void WritePush(byte[] data, string segment, string headAddress, string pushType, string coin, string sn)
        {
            DateTime d        = DateTime.Now;
            string   filePath = "";
            string   fileName = "";

            filePath = string.Format("log\\SN\\{0}-{1}\\{2}\\{3}", segment, headAddress, d.ToString("yyyy"), d.ToString("yyyy-MM"));
            fileName = d.ToString("yyyy-MM-dd HH") + " PUSH.txt";
            try
            {
                Directory.CreateDirectory(filePath);
                StreamWriter sw = new StreamWriter(filePath + "\\" + fileName, true, Encoding.GetEncoding("gb2312"));
                sw.WriteLine("接收时间:" + d.ToString());
                sw.WriteLine("原始数据:" + PubLib.BytesToString(data));
                sw.WriteLine("投币类别:" + pushType);
                sw.WriteLine("投币数:" + coin);
                sw.WriteLine("投币流水:" + sn);
                sw.WriteLine();
                sw.Flush();
                sw.Close();
            }
            catch { }
        }