/// <summary> /// Start /// </summary> /// <param name="collection">Components</param> /// <param name="timeUnit">Time unit</param> /// <param name="isAbsoluteTime">Components</param> /// <param name="realtimeStep">Realtime step</param> /// <param name="dataConsumer">Data consumer</param> public static IRealtime StartRealtime(this IComponentCollection collection, TimeType timeUnit, bool isAbsoluteTime, IAsynchronousCalculation realtimeStep, IDataConsumer dataConsumer, IEventLog log, string reason) { if (reason.Equals(StaticExtensionEventInterfaces.Realtime)) { if (currentRuntime != null) { throw new Exception(); } start(reason); currentRuntime = Runtime.Start(collection, timeUnit, isAbsoluteTime, realtimeStep, dataConsumer, log, reason); if (currentRuntime == null) { stop(); } } else { start(reason); return(Runtime.Start(collection, timeUnit, isAbsoluteTime, realtimeStep, dataConsumer, log, reason)); } return(currentRuntime); }
/// <summary> /// Connect to Log /// </summary> /// <param name="reader">The reader</param> /// <param name="log">Log</param> /// <param name="name">Name of the reader</param> public static void ConnectLog(this IEventReader reader, IEventLog log, string name) { if (reader is INativeReader) { readers.Add(new EventReaderLink(reader, log, name)); } }
static void Main(string[] args) { using (ChannelFactory <IEventLog> channelFactory1 = new ChannelFactory <IEventLog>("eventLogService")) { IEventLog proxy = channelFactory1.CreateChannel(); string source = "...<<source>>..."; string message = "...<<message>>..."; EventLogEntryType logEntryType = EventLogEntryType.Error; int eventId = 123; short category = 456; proxy.WriteEntry(source, message, logEntryType, eventId, category); } using (ChannelFactory <IInstrumentation> channelFactory2 = new ChannelFactory <IInstrumentation>("instrumentationservice")) { IInstrumentation proxy = channelFactory2.CreateChannel(); string performanceCounterCategory = "...<<category>>..."; string performanceCounterName = "...<<performance name>>..."; string wmiPropertyName = "...<<WMI Properpty Name>>..."; string wmiPropertyValye = "...<<>WMI Property Value>..."; proxy.IncreasePerformanceCounter(performanceCounterCategory, performanceCounterName); proxy.SetWmiProperty(wmiPropertyName, wmiPropertyValye); } Console.Read(); }
/// <summary> /// Instance a new Stack Client plugin container. /// </summary> /// <param name="defaults">Defaults values for queries executed against this client.</param> /// <param name="handler">A request handler for this client.</param> /// <param name="logger">Event log message dispatcher.</param> /// <param name="cache">API Response cache store.</param> /// <param name="throttler">Request throttler.</param> public StackClientPlugins(IDefaults defaults, IRequestHandler handler, IEventLog logger, IResponseCache cache, IRequestThrottler throttler) { if (defaults == null) { throw new ArgumentNullException("defaults"); } if (handler == null) { throw new ArgumentNullException("handler"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (cache == null) { throw new ArgumentNullException("cache"); } if (throttler == null) { throw new ArgumentNullException("throttler"); } Default = defaults; RequestHandler = handler; EventLog = logger; Cache = cache; Throttler = throttler; }
protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { IWorkContext context = (request.Properties.Get <IWorkContext>() ?? WorkContext.Empty) .WithTag(_tag); IEventLog eventLog = request.Properties.Get <IEventLog>() ?? NetEventSource.Log; var logDetails = new List <string>(); logDetails.Add($"Method: {request.Method}"); logDetails.Add($"Uri:{request.RequestUri}"); if (request.Headers.Count() > 0) { logDetails.Add($"Headers: {request.Headers.Select(x => x.Key + "=" + x.Value).Aggregate(";")}"); } try { using (var scope = new ActivityScope(context, string.Join(",", logDetails), eventLog)) { HttpResponseMessage response = await base.SendAsync(request, cancellationToken); logDetails.Add($"Response: StatusCode: {response.StatusCode}"); eventLog.Verbose(context, string.Join(",", logDetails)); return(response); } } catch (Exception ex) { eventLog.Error(context, string.Join(",", logDetails), ex); throw; } }
public OculiServiceLogTraceListener(IEventLog eventLog, IFileSystem fileSystem, int maxLogFileSizeBytes) { this.fileSystem = fileSystem; this.eventLog = eventLog; this.maxLogFileSizeBytes = maxLogFileSizeBytes; this.oculiServiceTraceListener = this.GetListener("OculiService.log"); }
/// <summary> /// Initializes a new instance of the <see cref="OrderService"/> class. /// </summary> /// <param name="principalProvider">The principal provider.</param> /// <param name="userDinnerStorage">The user dinner storage.</param> /// <param name="calendarService">The calendar service.</param> /// <param name="eventLog">The event log.</param> public OrderService(IDinnerPrincipalProvider principalProvider, IUserDinnerStorage userDinnerStorage, ICalendarService calendarService, IEventLog eventLog) { this.principalProvider = principalProvider; this.userDinnerStorage = userDinnerStorage; this.calendarService = calendarService; this.eventLog = eventLog; }
internal EventLogLink(IEvent ev, IEventLog log, string name) { this.ev = ev; this.log = log; this.name = name; ev.Event += Log; }
private static IActivityEvent ComposeHelpfulMarkGivenEvent(IEventLog eventLog, Dictionary <int, IUser> userDictionary, IList <UserProfile> users, IList <HelpfulMarkGivenEvent> helpfulMarks) { var evt = helpfulMarks.SingleOrDefault(y => y.EventLogId == eventLog.EventLogId); if (evt == null) { return(null); } LogCommentEvent logComment = evt.LogComment; if (logComment == null) { var connection = new SqlConnection(StringConstants.ConnectionString); string query = "SELECT * FROM LogCommentEvents WHERE Id = @logCommentEventId "; logComment = connection.Query <LogCommentEvent>(query, new { logCommentEventId = evt.LogCommentEventId }).SingleOrDefault(); } return(new HelpfulMarkGivenEvent() { EventId = evt.EventId, EventLogId = evt.EventLogId, EventDate = evt.EventDate, SenderId = evt.Sender == null ? eventLog.SenderId : evt.Sender.IUserId, Sender = GetUser(userDictionary, users, eventLog.SenderId), SolutionName = evt.SolutionName, LogCommentEventId = evt.LogCommentEventId, LogComment = evt.LogComment == null ? logComment : evt.LogComment }); }
/// <summary> /// Set event log /// </summary> /// <param name="eventLog">event log</param> /// <returns>this</returns> public WorkContextBuilder Set(IEventLog eventLog) { Verify.IsNotNull(nameof(eventLog), eventLog); EventLog = eventLog; return(this); }
private static IActivityEvent ComposeExceptionEvent(IEventLog eventLog, Dictionary <int, IUser> userDictionary, IEnumerable <IUser> users, IEnumerable <ExceptionEvent> exceptions) { var evt = exceptions.SingleOrDefault(y => y.EventLogId == eventLog.EventLogId); if (evt == null) { return(null); } return(new ExceptionEvent(evt.EventDate) { EventId = evt.EventId, EventLogId = eventLog.EventLogId, SenderId = eventLog.SenderId, Sender = GetUser(userDictionary, users, eventLog.SenderId), SolutionName = evt.SolutionName, DocumentName = evt.DocumentName, ExceptionAction = evt.ExceptionAction, ExceptionCode = evt.ExceptionCode, ExceptionDescription = evt.ExceptionDescription, ExceptionType = evt.ExceptionType, LineContent = evt.LineContent, LineNumber = evt.LineNumber }); }
internal EventReaderLink(IEventReader reader, IEventLog log, string name) { this.reader = reader; this.log = log; this.name = name; reader.EventData += Log; }
public TasksViewModel(ITasksService tasksService, IPlaybackControl playbackControl, IEventLog eventLog, ILogger logger) { this.tasksService = tasksService; this.playbackControl = playbackControl; this.eventLog = eventLog; this.logger = logger; this.ModalitiesSelection = Selection <Modality> .FromEnum(); this.Genders = Selection <Gender> .FromEnum(); this.Proband = new Proband(); this.Tasks = new ReactiveList <TvControlTaskViewModel> { ChangeTrackingEnabled = true }; this.Reset = ReactiveCommand.Create(ResetImplementation); this.Save = ReactiveCommand.CreateFromTask(this.SaveAsync); this.Add = ReactiveCommand.Create(this.AddImpl); this.StartStop = ReactiveCommand.Create(this.StartStopImpl); this.SetFinished = ReactiveCommand.Create <bool, Unit>(this.SetFinishedImpl, this.WhenAnyValue(model => model.CurrentTask).Select(model => model != null)); this.InitAsync(); }
/// <summary> /// Constructor /// </summary> public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex, IThreadMonitor callMonitor) : base(threadIndex) { SafeDebug.AssertNotNull(callMonitor, "callMonitor"); this.log = log; this.threadIndex = threadIndex; this.callMonitor = callMonitor; this.callStack = new SafeLinkedList <CallFrame>(); this.current = new CallFrame(default(ICallFrame), default(Method), 0); //fake caller. this.callStack.AddFirst(new SafeLinkedList <CallFrame> .Node(this.current)); if (firstTime) { // get rid of all [T] from types and methods var env = MyEngine.EnvironmentVars; firstTime = false; foreach (var t in env.DontPreemptTypes) { newDontPreemptTypes.Add(eliminateParameterizedTypes(t)); } foreach (var m in env.DontPreemptMethods) { newDontPreemptMethods.Add(eliminateParameterizedTypes(m)); } foreach (var m in env.PrioritizeMethods) { newPrioritizeMethods.Add(eliminateParameterizedTypes(m)); } } }
public UsersModule(IUsers users, IPasswordGenerator passwordGenerator, IHashing hashing, IEmailGateway emailGateway, IEventLog eventLog) : base("/User") { this.users = users; this.passwordGenerator = passwordGenerator; this.hashing = hashing; this.emailGateway = emailGateway; this.eventLog = eventLog; Post["/"] = x => { var email = Request.Query.email.ToString(); if (!string.IsNullOrEmpty(email)) { var fromDb = this.users.Get(email); if (fromDb != null) return Response.AsJson(new[] {fromDb}); var password = this.users.Create(email); return Response.AsJson(new[] {new {password}}); } return Response.AsJson(Enumerable.Empty<string>()); }; Get["/PasswordReset"] = x => { return View["passwordreset", new Result { Success = false }]; }; Post["/PasswordReset"] = x => { bool result = false; var input = this.Bind<PasswordResetBody>(); if(!string.IsNullOrWhiteSpace(input.email)) { var user = this.users.Get(input.email); if(user!= null) { var password = this.passwordGenerator.Generate(); var hashedPassword = this.hashing.Hash(password); this.users.ChangePassword(user.Id, hashedPassword); this.emailGateway.SendNewPasswordEmail(user.Email, password); result = true; this.eventLog.LogEvent(new Event() { AuthorId = user.Id, BarCodeId = null, EventName = "CHANGEPASSWORD", Ip = this.Request.Headers["X-Forwarded-For"].FirstOrDefault() }); } } return View["passwordreset", new Result { Success = result }]; }; }
public EventLogPageVM( IEventLog eventLog, IProjects projects) { this.eventLog = eventLog; this.projects = projects; ReadLogText(); }
/// <summary> /// Converts an XML string to JSON /// </summary> /// <param name="xml">String containing valid XML</param> /// <param name="eventLog"></param> /// <returns>string containing JSON</returns> public static string XmlToJson(string xml, IEventLog eventLog) { // To convert an XML node contained in string xml into a JSON string var doc = new XmlDocument(); doc.LoadXml(xml); return(JsonConvert.SerializeXmlNode(doc)); }
public void Initialize() { _usersApi = Apis.Get <IUsers>(); _eventLogApi = Apis.Get <IEventLog>(); SamlEvents.Instance.AfterAuthenticate += Instance_AfterAuthenticate; SamlEvents.Instance.AfterCreate += Instance_AfterCreate; }
public void LogUserActivity(string txt) { lock (m_sysLogger) { IEventLog log = m_sysLogger.LogEvent(txt, DateTime.Now, EventType_t.Activity); SysLogAdded?.Invoke(log); } }
private void LogManager_ClientLogAdded(uint clID, IEventLog log) { ActiveClientsQueue.IClientData clData = m_onlineClients.Get(clID); if (clData != null) { clData.AddLog(log); } }
/// <summary> /// Create new context with cancellation token /// </summary> /// <param name="eventLog">event log to use</param> /// <returns>new work context</returns> public IWorkContext With(IEventLog eventLog) { Verify.IsNotNull(nameof(eventLog), eventLog); return(new WorkContext(this) { EventLog = eventLog, }); }
/// <summary> /// Initializes a new instance of the <see cref="AuditLogEventLogWriter" /> class. /// </summary> /// <param name="eventLog">The event log.</param> /// <exception cref="System.ArgumentNullException">eventLog</exception> public AuditLogEventLogWriter(IEventLog eventLog) { if (eventLog == null) { throw new ArgumentNullException(nameof(eventLog)); } _eventLog = eventLog; }
public RetailsController( IRetailRepository retailRepository, IGroupRepository groupRepository, IEventLog eventLog) { _retailRepository = retailRepository; _eventLog = eventLog; _groupRepository = groupRepository; }
public static void AddEventLogs(IEventLog eventLog) { EventLogs.Enqueue(eventLog); if (OnNewEventLog != null) { OnNewEventLog(eventLog); } }
public void Initialize() { _userProfileFields = Apis.Get <IUserProfileFields>(); _usersApi = Apis.Get <IUsers>(); _eventLogApi = Apis.Get <IEventLog>(); SamlEvents.Instance.AfterAuthenticate += Instance_AfterAuthenticate; SamlEvents.Instance.AfterCreate += Instance_AfterCreate; _usersApi.Events.BeforeUpdate += Events_BeforeUpdate; }
public void InsertEvent(IEventLog data) { var db = new TooksCmsDAL(); var e = EventLog.CreateEventLog(data); db.EventLogs.Add(e); db.SaveChanges(); }
protected BaseLogger(ILog log, string eventSourceName, string eventLogName, IEventLog proxy) { Log = log; _eventSourceName = eventSourceName; EventLog = proxy; if (string.IsNullOrEmpty(eventSourceName)) return; if (!EventLog.SourceExists(eventSourceName)) EventLog.CreateEventSource(eventSourceName, eventLogName); }
/// <summary> /// Constructor. /// </summary> /// <param name="log">IEventLog</param> /// <param name="threadIndex">Thread index</param> /// <param name="callMonitor">IThreadMonitor</param> /// <param name="raceDetectionEngine">IRaceDetectionEngine</param> /// <param name="configuration">Configuration</param> public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex, IThreadMonitor callMonitor, IRegisterRuntimeOperation raceDetectionEngine, Configuration configuration) : base(threadIndex) { SafeDebug.AssertNotNull(callMonitor, "callMonitor"); this.ThreadIndex = threadIndex; this.Configuration = configuration; this.DebugTrace = new SafeList <string>(); this.CallStack = new SafeStack <Method>(); this.Reporter = raceDetectionEngine; }
//handlers: private void LogManager_SysLogAdded(IEventLog log) { if (InvokeRequired) { BeginInvoke(new Action <IEventLog>(AddLog), log); } else { AddLog(log); } }
/// <summary> /// Construct scope /// </summary> /// <param name="context">work context</param> /// <param name="message">message (optional)</param> /// <param name="eventLog">event log (optional, default is toolbox's event source</param> public ActivityScope(IWorkContext context, string message = null, IEventLog eventLog = null) { Verify.IsNotNull(nameof(context), context); Context = context; EventLog = eventLog ?? ToolboxEventSource.Log; Message = message; Stopwatch = Stopwatch.StartNew(); EventLog.ActivityStart(Context, Message); }
public static EventLog CreateEventLog(IEventLog data) { return(new EventLog { EventLogUid = data.EventLogUid, EventType = (byte)data.EventType, EventSource = data.EventSource, Description = data.Description, EventId = data.EventId }); }
public SyncService(TaskService taskService) { _task = new QueryHandlerTask { ApiKey = AdminManager.GetConfig().YoutubeApiKey, ScheduledTaskInfo = taskService.ScheduledTaskInfo, TaskCancellation = taskService.Token, TraceId = taskService.TraceId }; _eventLog = taskService.EventLog; _taskCancellationToken = taskService.Token; }
/// <summary> /// Constructor. /// </summary> /// <param name="name">The name of the repository.</param> /// <param name="path">The path of the repository,</param> /// <param name="tokenProvider">The token provider.</param> /// <param name="eventLog">The event log.</param> /// <param name="cleanupInterval">Cleanup interval for the repository.</param> /// <param name="retentionPeriod">The retention period for the repository</param> public FileRepository(string name, string path, IFileTokenProvider tokenProvider, IEventLog eventLog, TimeSpan retentionPeriod, TimeSpan cleanupInterval) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException(nameof(path)); } if (tokenProvider == null) { throw new ArgumentNullException(nameof(tokenProvider)); } if (eventLog == null) { throw new ArgumentNullException(nameof(eventLog)); } if (retentionPeriod.TotalMilliseconds <= 0) { throw new ArgumentOutOfRangeException(nameof(retentionPeriod)); } if (cleanupInterval.TotalMilliseconds <= 0) { throw new ArgumentOutOfRangeException(nameof(cleanupInterval)); } // Try and create the file repository path if it does not exist if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } eventLog.WriteInformation("Creating file repository {0} at {1}.", name, path); Name = name; _repositoryPath = path.TrimEnd(Path.DirectorySeparatorChar); _tokenProvider = tokenProvider; _eventLog = eventLog; _cleanupInterval = cleanupInterval; _retentionPeriod = retentionPeriod; // Get the temp directory path _tempDirectoryPath = Path.Combine(path, TempDirectory); Directory.CreateDirectory(_tempDirectoryPath); }
public BarCodesModule(IUsers users, IEventLog eventLog, IBarCodeController barCodeController) : base("/BarCode") { this.RequiresAuthentication(); this.users = users; this.eventLog = eventLog; this.barCodeController = barCodeController; Get["/{id}"] = x => { var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName); var barcode = this.barCodeController.Get(x.id, userId); this.Log(barcode, userId, "GET"); return Response.AsJson(new[] { barcode }); }; Get["/{format}/{code}"] = x => { if (x.format == null || x.code == null) return Response.AsJson(Enumerable.Empty<BarCode>()); var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName); BarCode barcode = this.barCodeController.Get(x.format, x.code, userId); this.Log(barcode, userId, "GET"); return Response.AsJson(new[] {barcode}); }; Post["/"] = x => { BarCode barCode = this.Bind<BarCode>(); var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName); var originalCode = this.barCodeController.Update(barCode, userId); this.Log(originalCode, userId, "UPDATE", barCode.Name); return Response.AsJson(new[] { originalCode }); }; Post["/Rate/{id}/{value}"] = x => { var userId = this.users.GetIdByUsername(this.Context.CurrentUser.UserName); var code = this.barCodeController.Rate(x.id, (Byte)x.value, userId); this.Log(x.id, userId, "RATE"); return Response.AsJson(new[] { code }); }; }
public CommentsModule(IBarCodes barCodes, IComments comments, IUsers users, IEventLog eventLog, IGravatarService gravatarService) : base("/Comment") { this.RequiresAuthentication(); this.barCodes = barCodes; this.comments = comments; this.users = users; this.eventLog = eventLog; this.gravatarService = gravatarService; Get["/{id}"] = x => { if (!this.barCodes.Exists(x.id)) return Response.AsJson(Enumerable.Empty<Comment>()); IEnumerable<Comment> commentsForBarCode = this.comments.GetCommentsForBarCode(x.id); Comment[] ret = this.gravatarService.AddAvatarToComments(commentsForBarCode).ToArray(); return Response.AsJson(ret); }; Post["/{id}"] = x => { if (!this.barCodes.Exists(x.id)) return Response.AsJson(Enumerable.Empty<Comment>()); Comment comment = this.Bind<Comment>(); comment.Author = this.users.GetIdByUsername(this.Context.CurrentUser.UserName); this.comments.Add(comment); Comment[] commentsForBarCode = this.comments.GetCommentsForBarCode(x.id).ToArray(); this.Log(x.id, comment.Author, "COMMENT", comment.Text); return Response.AsJson(commentsForBarCode); }; }
/// <summary> /// Initialize the service. /// </summary> /// <param name="eventLog">Event log.</param> public static void Initialize(IEventLog eventLog) { _eventLog = eventLog; }
/// <summary> /// Constructor. /// </summary> /// <param name="log">IEventLog</param> /// <param name="threadIndex">Thread index</param> /// <param name="callMonitor">IThreadMonitor</param> /// <param name="testingEngine">ITestingEngine</param> /// <param name="configuration">Configuration</param> public ThreadExecutionMonitorDispatcher(IEventLog log, int threadIndex, IThreadMonitor callMonitor, ITestingEngine testingEngine, Configuration configuration) : base(threadIndex) { SafeDebug.AssertNotNull(callMonitor, "callMonitor"); this.ThreadIndex = threadIndex; this.Configuration = configuration; this.ThreadTrace = new List<ThreadTrace>(); this.DebugTrace = new SafeList<string>(); this.CallStack = new SafeStack<Method>(); this.IsDoHandlerCalled = false; this.IsEntryActionCalled = false; this.IsExitActionCalled = false; this.IsAction = false; this.RecordRW = false; this.IsCreateMachineMethod = false; // Registers a callback to emit the thread trace. The callback // is invoked at the end of each testing iteration. testingEngine.RegisterPerIterationCallBack(EmitThreadTrace); }
public FileLogger(ILog log, string eventSourceName, string eventLogName, IEventLog eventLog) : base(log, eventSourceName, eventLogName, eventLog) { Name = eventSourceName; }
/// <summary> /// Logs an exception to the event log. /// </summary> /// <param name="e">The exception to log.</param> /// <param name="log">The event log to log the exception to.</param> /// <returns>True if the exception was logged successfully. False otherwise.</returns> private static bool LogException(Exception e, IEventLog log) { if (log != null) { log.Log(new Event(typeof(ConfigurationItem).FullName, DateTime.Now, Event.SeverityLevels.Error, e.GetType().FullName, "Description:\n" + e.Message + "\n" + "Stack Trace:\n" + e.StackTrace)); return true; } else { return false; } }
public void SetLog(IEventLog log) { mLog = log; Context.Current.Log = log; }
public TaskService(ScheduledTaskDto scheduledTask) { EventLog = new EventLog(); ScheduledTaskInfo = scheduledTask; scheduledTask.History = (EventLog) EventLog; TokenSource = new CancellationTokenSource(); Token = TokenSource.Token; }
/// <summary> /// Called when the service is being stopped by the SCM. /// </summary> protected override void OnStop() { LogInfo("Stopping service..."); try { ModuleSupervisor.Shutdown(); TaskSupervisor.Shutdown(); LogInfo("Service successfully stopped..."); } catch (Exception e) { LogError("Unable to stop service.", e); throw; } lock (_eventLog) { _eventLog.Close(); _eventLog = null; } }
private void InitializeModel() { this.InitializeCommands(); this.LoadSettingsModel(); this._repository = this.Container.Resolve<ITorrentRepository>(new ParameterOverride("filepath", this.SettingsModel.RepositoryFile)); this._eventLog = this.Container.Resolve<IEventLog>(new ParameterOverride("filepath", this.SettingsModel.LogFile)); this.LoadModel(); this.SetupTimer(); this.SetupBackgroundWorker(); }