Esempio n. 1
0
 public static void WriteLine(string format, params string[] list)
 {
     lock (Common._lockLog)
     {
         if (Common._cfgFile == null)
         {
             Common._logFile = "";
             Common._cfgFile = ValuePairs.LoadValueKeyFromXML(Common._xmlFile);
             if (Common._cfgFile.ContainsKey("LogFile"))
             {
                 Common._logFile = Common._cfgFile["LogFile"];
             }
         }
         if (Common._logFile != null && !(Common._logFile == ""))
         {
             try
             {
                 string   str  = string.Format(format, list);
                 DateTime now  = DateTime.Now;
                 string   str2 = now.ToString("MM-dd HH:mm:ss.fff");
                 string   text = Common.sCodebase + "\\debuglog\\" + Common._logFile;
                 int      num  = text.LastIndexOf(".");
                 if (num >= 0)
                 {
                     text = text.Substring(0, num);
                 }
                 if (DispatchAPI.IsServerRole())
                 {
                     text = text + "(" + now.ToString("yyyy-MM-dd") + ")s.log";
                 }
                 else
                 {
                     text = text + "(" + now.ToString("yyyy-MM-dd") + ")c.log";
                 }
                 using (StreamWriter streamWriter = File.AppendText(text))
                 {
                     if (DispatchAPI.IsServerRole())
                     {
                         streamWriter.WriteLine(str2 + " [S] " + str, streamWriter);
                     }
                     else
                     {
                         streamWriter.WriteLine(str2 + " [-] " + str, streamWriter);
                     }
                 }
             }
             catch (Exception)
             {
             }
         }
     }
 }
Esempio n. 2
0
        public static void CompressThread(object threadInfo)
        {
            DispatchAttribute dispatchAttribute = (DispatchAttribute)threadInfo;

            byte[] data  = dispatchAttribute.data;
            byte[] array = null;
            if (DispatchAPI.IsLocalConnection())
            {
                dispatchAttribute.algorithm = 0;
            }
            try
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    if (dispatchAttribute.algorithm != 2)
                    {
                        if (dispatchAttribute.algorithm == 1)
                        {
                            using (GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress))
                            {
                                gZipStream.Write(data, 0, data.Length);
                                gZipStream.Close();
                                memoryStream.Close();
                                array = memoryStream.ToArray();
                                gZipStream.Dispose();
                                memoryStream.Dispose();
                                goto IL_8E;
                            }
                        }
                        if (dispatchAttribute.algorithm == 0)
                        {
                            array = dispatchAttribute.data;
                        }
                    }
                    IL_8E :;
                }
            }
            catch (Exception ex)
            {
                Common.WriteLine("CompressThread: " + ex.Message, new string[0]);
                array = null;
            }
            if (array == null || array.Length == 0)
            {
                return;
            }
            double num = (double)array.Length;

            num /= (double)data.Length;
            if (array != null)
            {
                if (dispatchAttribute.type == 1024)
                {
                    byte[] bytes  = BitConverter.GetBytes(dispatchAttribute.cid);
                    byte[] array2 = new byte[8 + array.Length];
                    Array.Copy(bytes, 0, array2, 0, bytes.Length);
                    Array.Copy(array, 0, array2, 8, array.Length);
                    array = array2;
                }
                dispatchAttribute.data = array;
                if (dispatchAttribute.cbCacheProcess != null)
                {
                    dispatchAttribute.cbCacheProcess(dispatchAttribute);
                }
                if (dispatchAttribute.cbCallBack != null)
                {
                    dispatchAttribute.cbCallBack(dispatchAttribute);
                }
            }
        }