예제 #1
0
        private string convertFileName(DateTime date, string fileName)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }
            Assembly assembly = GlobalConfiguration.GetAssembly();

            if (fileName.Contains("<AssemblyName>"))
            {
                fileName = fileName.Replace("<AssemblyName>", assembly.GetName().Name);
            }
            if (fileName.Contains("$assembly"))
            {
                fileName = fileName.Replace("$assembly", assembly.GetName().Name);
            }
            if (fileName.Contains("$year"))
            {
                fileName = fileName.Replace("$year", string.Format("{0:yyyy}", (object)date));
            }
            if (fileName.Contains("$month"))
            {
                fileName = fileName.Replace("$month", string.Format("{0:MM}", (object)date));
            }
            if (fileName.Contains("$day"))
            {
                fileName = fileName.Replace("$day", string.Format("{0:dd}", (object)date));
            }
            return(fileName);
        }
예제 #2
0
 private static string getTraceFileName(Assembly assembly)
 {
     string empty = string.Empty;
     string str1;
     if (!string.IsNullOrEmpty(GlobalTracer.CustomLogFileName))
     {
         str1 = GlobalTracer.CustomLogFileName;
     }
     else
     {
         str1 = GlobalConfiguration.AppSettings["LogFilePath"];
         if (string.IsNullOrEmpty(str1))
             str1 = string.Format("{0}.log", (object)GlobalConfiguration.GetAssembly().GetName().Name);
     }
     string str2;
     switch (GlobalConfiguration.Mode)
     {
         case RunMode.EncompassServer:
             str2 = string.Format("{0}Settings\\Logs\\{1}", (object)string.Format("{0}{1}", (object)Session.EncompassDataDirectory, Session.EncompassDataDirectory.EndsWith("\\") ? (object)string.Empty : (object)"\\"), (object)str1);
             break;
         case RunMode.WebServer:
         case RunMode.Client:
             if (string.IsNullOrEmpty(str1))
             {
                 str1 = string.Format("{0}.log", (object)GlobalConfiguration.GetAssembly().GetName().Name);
             }
             else
             {
                 FakedDataCollection fakedDataCollection = new FakedDataCollection();
                 fakedDataCollection.Silent = true;
                 string result;
                 if (fakedDataCollection.ExecuteTranslation(str1, out result, out string _))
                     str1 = result;
             }
             FileInfo fileInfo = new FileInfo(str1);
             if (string.IsNullOrEmpty(fileInfo.DirectoryName) || !str1.StartsWith(fileInfo.DirectoryName))
             {
                 string fileName;
                 switch (GlobalConfiguration.Mode)
                 {
                     case RunMode.WebServer:
                         fileName = HttpContext.Current.Server.MapPath(str1);
                         break;
                     case RunMode.Client:
                         fileName = string.Format("{0}\\{1}", (object)Environment.CurrentDirectory, (object)str1);
                         break;
                     default:
                         fileName = string.Format("{0}\\{1}", (object)AppDomain.CurrentDomain.BaseDirectory, (object)str1);
                         break;
                 }
                 fileInfo = new FileInfo(fileName);
             }
             str2 = fileInfo.FullName;
             break;
         default:
             str2 = string.Format("{0}.log", (object)GlobalConfiguration.GetAssembly().GetName().Name);
             break;
     }
     return str2;
 }
예제 #3
0
 public static void Init()
 {
     Assembly assembly = GlobalConfiguration.GetAssembly();
     if (GlobalTracer.__cache.ContainsKey(assembly))
         return;
     lock (typeof(GlobalTracer))
     {
         if (GlobalTracer.__cache.ContainsKey(assembly))
             return;
         ITracer tracer = GlobalTracer.createTracer(assembly);
         GlobalTracer.__cache.Add(assembly, tracer);
     }
 }
예제 #4
0
 public override void Log(TraceLevel level, string message, string className)
 {
     if (!this.Initialize)
     {
         lock (this)
         {
             if (!this.Initialize)
             {
                 bool isToday = false;
                 try
                 {
                     IList <string> purgedFiles = this.getPurgedFiles(this.Now, this.FileName, out isToday);
                     if (purgedFiles.Count > 0)
                     {
                         foreach (string fileName in (IEnumerable <string>)purgedFiles)
                         {
                             try
                             {
                                 this.Session.DataExchange.DeleteCustomDataObject(fileName);
                             }
                             catch (Exception ex)
                             {
                             }
                         }
                     }
                 }
                 finally
                 {
                     try
                     {
                         if (!isToday)
                         {
                             GlobalConfiguration.AppSettings["ServerLogPurgeDate"] = DateTime.Today.ToString();
                             GlobalConfiguration.Save((object)this.Session, true);
                         }
                     }
                     catch (Exception ex)
                     {
                     }
                     this.Initialize = true;
                 }
             }
         }
     }
     if (level > (TraceLevel)this.LogLevel)
     {
         return;
     }
     GlobalConfiguration.GetAssembly();
     object[] objArray = new object[7]
     {
         (object)this.GetLevelText(level),
         (object)this.Session.GetServerTime(),
         (object)this.Session.UserID,
         (object)this.Session.ID,
         (object)Environment.MachineName,
         (object)message,
         (object)className
     };
     this.WriteToServer(string.Format(string.Format("{0}\r\n", (object)string.Join("|", ((IEnumerable <object>)objArray).Select <object, string>((Func <object, int, string>)((o, i) => "{" + i.ToString() + "}")).ToArray <string>())), objArray));
 }