Exemple #1
0
        protected override void Execute(CodeActivityContext context)
        {
            console = ActivityConsole.GetDefaultOrNew(context);

            string machineName = MachineName.Get(context);

            machineName = (string.IsNullOrEmpty(machineName) ? "." : machineName);

            bool throwOnError         = ThrowOnError.Get(context);
            bool treatExistsAsSuccess = TreatExistAsSuccess.Get(context);

            string errorMessage = "An unknown error has occurred.";
            bool   created      = CreateLogSource(machineName, EventLogName.Get(context), EventLogSource.Get(context), out errorMessage, treatExistsAsSuccess);

            if (created)
            {
                console.WriteLine(string.Format("Successfully created or verified event log and source : {0} - {1}", EventLogName.Get(context), EventLogSource.Get(context)));
            }
            else
            {
                if (throwOnError)
                {
                    throw new ArgumentException(errorMessage);
                }
                else
                {
                    console.WriteLine(string.Format("Error : {0}", errorMessage));
                }
            }
        }
 public SearchCriteria(EventLogName logName, string machineName = null, string logSearch = null, DateTime?startDateTime = null, DateTime?endDateTime = null)
 {
     LogName       = logName;
     MachineName   = machineName;
     LogSearch     = logSearch;
     StartDateTime = startDateTime;
     EndDateTime   = endDateTime;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="logName">Name of the log to write to.</param>
 /// <param name="machineName">Name of machine where log is located.</param>
 /// <param name="eventSource">Source of the event log entries.</param>
 public WindowsLog(EventLogName logName, string machineName, string eventSource)
 {
     InitEventLog(logName.ToString(), machineName, eventSource);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="logName">Name of the log to write to.</param>
 /// <param name="machineName">Name of machine where log is located.</param>
 public WindowsLog(EventLogName logName, string machineName)
 {
     InitEventLog(logName.ToString(), machineName, string.Empty);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="logName">Name of the log to write to.</param>
 public WindowsLog(EventLogName logName)
 {
     InitEventLog(logName.ToString(), string.Empty, string.Empty);
 }