Example #1
0
        public static void WriteLogWhenLoginSuccessful(long? startTrick, long? endTrick, long elapsedMilliseconds)
        {
            MonitoringPopulateLogEntry utility = new MonitoringPopulateLogEntry();

            Guid id = Guid.NewGuid();

            MonitoringLogEntry entry = new MonitoringLogEntry();
            entry.TracingStartTicks = startTrick;
            entry.TracingEndTicks = endTrick;
            decimal secondsElapsed = utility.GetSecondsElapsed(elapsedMilliseconds);
            entry.SecondsElapsed = secondsElapsed;

            entry.MethodName = "HiiP.Framework.Security.AccessControl.Authentication.Authenticate";
            entry.ParameterValues = "void";

            entry.ExtendedActivityId = id.ToString();
            entry.UserID = AppContext.Current.UserID;
            entry.UserName = AppContext.Current.UserName;
            entry.UserRoles = AppContext.Current.UserRoles;
            entry.UserGraphicArea = AppContext.Current.GraphicArea;
            //entry.Organization = AppContext.Current.Organization;
            entry.Office = AppContext.Current.Office;
            entry.IpAddress =AppContext.Current.IPAddress;
            entry.Categories.Add("Trace");
            entry.Title = "Login Successful";
            entry.Message = "Login Successful";
            entry.ModuleId = "Login";
            entry.FunctionId = "Login";
            entry.Severity = TraceEventType.Information;
            entry.Component = ComponentType.BusinessService;

            if (Logger.ShouldLog(entry))
            {
                Logger.Write(entry);
            }
        }
        private void LogPostCall(IMethodInvocation input, IMethodReturn result, Stopwatch stopwatch, Nullable<long> tracingStartTicks)
        {
            //if (logAfterCall)
            {
                MonitoringPopulateLogEntry utility = new MonitoringPopulateLogEntry();

                if (FunctionId != null)
                {
                    AppContext.Current.FunctionID = FunctionId;
                }

                if (ModuleId != null)
                {
                    AppContext.Current.ModuleID = ModuleId;
                }

                utility.PopulateLogEntryForCallHandler(input,
                    //categories,
                    //includeParameters, includeCallStack,
                    result,
                    tracingStartTicks,
                    Stopwatch.GetTimestamp(),
                    (stopwatch==null)?0:stopwatch.ElapsedMilliseconds,
                    Resources.EndTrace,
                    AppContext.Current.ModuleID,
                    AppContext.Current.FunctionID,
                    Component);

            }
        }
Example #3
0
        //Uncalled method
        //private void WriteTraceStartMessage()
        //{
        //    MonitoringPopulateLogEntry utility = new MonitoringPopulateLogEntry();
        //    MonitoringLogEntry logEntry = utility.PopulateLogEntryForTrace(true);
        //    logEntry.TracingStartTicks = tracingStartTicks;
        //    logEntry.MethodName = GetExecutingMethodName();
        //    string message = string.Format(Resources.Culture, Resources.StartTrace, logEntry.ActivityId, logEntry.MethodName, logEntry.TracingStartTicks);
        //    logEntry.Message = message;
        //    logEntry.Component = Component;
        //    logEntry.ModuleId = ModuleId;
        //    logEntry.FunctionId = FunctionId;
        //    LogWriter writer = GetWriter();
        //    writer.Write(logEntry);
        //}
        private void WriteTraceEndMessage()
        {
            MonitoringPopulateLogEntry utility = new MonitoringPopulateLogEntry();
            MonitoringLogEntry logEntry = utility.PopulateLogEntryForTrace(false);
            long tracingEndTicks = Stopwatch.GetTimestamp();
            decimal secondsElapsed = utility.GetSecondsElapsed(stopwatch.ElapsedMilliseconds);
            logEntry.TracingStartTicks = tracingStartTicks;
            logEntry.TracingEndTicks = tracingEndTicks;
            logEntry.SecondsElapsed = secondsElapsed;
            logEntry.MethodName = GetExecutingMethodName();
            string message = string.Format(Resources.Culture, Resources.EndTrace, logEntry.ActivityId, logEntry.MethodName, logEntry.TracingEndTicks, logEntry.SecondsElapsed);
            logEntry.Message = message;
            logEntry.Component = Component;
            logEntry.ModuleId = ModuleId;
            logEntry.FunctionId = FunctionId;
            LogWriter logWriter = GetWriter();

            using (BackgroundWorker worker = new BackgroundWorker())
            {
                worker.DoWork += delegate
                {
                    AppContext.SetToCallContext(AppContext.Current.ToDictionary());
                    logWriter.Write(logEntry);
                };

                worker.RunWorkerAsync();
            }
            instrumentationListener.TracerOperationEnded(PeekLogicalOperationStack() as string, stopwatch.ElapsedMilliseconds);
        }