Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/02/11 15:23:59 (13 years ago)
Author:
cneumuel
Message:

#1233

  • changed the way lifecycle methods are called. The new service method TriggerLifecycle checks when the latest cleanup was made and performs one (if necessary). This can also be called by an external program (like a windows task)
  • robustified logging
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/Logger.cs

    r5511 r5593  
    11using System;
    22using System.Diagnostics;
     3using System.Security;
     4using System.Threading;
    35
    46namespace HeuristicLab.Services.Hive.Common {
     
    1719    private EventLog log;
    1820
     21    /// <summary>
     22    /// Creating an EventSource requires certain permissions, which by default a IIS AppPool user does not have.
     23    /// In this case just ignore security exceptions.
     24    /// In order to make this work, the eventsource needs to be created manually
     25    /// </summary>
    1926    public Logger(string name, string source) {
    20       //if (!EventLog.SourceExists(name)) {
    21       //  EventLog.CreateEventSource(source, name);
    22       //}
    23       //log = new EventLog(name);
    24       //log.Source = source;
     27      try {
     28        if (!EventLog.SourceExists(source)) {
     29          EventLog.CreateEventSource(source, name);
     30        }
     31        log = new EventLog(name);
     32        log.Source = source;
     33      }
     34      catch (SecurityException) { }
    2535    }
    2636
    2737    public void Log(string message) {
    28       //log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Information);
     38      try {
     39        log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Information);
     40      }
     41      catch (SecurityException) { }
    2942    }
    3043
    3144    public void Error(Exception e) {
    32       //log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", e.Message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Error);
     45      try {
     46        log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", e.Message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Error);
     47      }
     48      catch (SecurityException) { }
    3349    }
    3450  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r5526 r5593  
    135135    Guid GetResourceId(string resourceName);
    136136
     137    [OperationContract]
     138    void TriggerLifecycle();
    137139    #endregion
    138140
Note: See TracChangeset for help on using the changeset viewer.