public void OnActionExecuted(ActionExecutedContext context)
 {
     if (context.Exception == null)
     {
         _tracker?.Stop();
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var fd = GetFlogDetail("starting application", null);

            Flogger.WriteDiagnostic(fd);

            var tracker = new PerfTracker("FloggerConsole_Execution", "", fd.UserName, fd.Location, fd.Product, fd.Layer);

            try
            {
                var ex = new Exception("Something bad has happened!");
                ex.Data.Add("input param", "nothing to see here");
                throw ex;
            }
            catch (Exception ex)
            {
                fd = GetFlogDetail("", ex);
                Flogger.WriteError(fd);
            }
            fd = GetFlogDetail("used flogging console", null);
            Flogger.WriteUsage(fd);
            fd = GetFlogDetail("stopping the application", null);
            Flogger.WriteDiagnostic(fd);

            tracker.Stop();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var detail = GetLogDetail("Starting Performance ", null);

            _perfTracker = new PerfTracker("SLoggerConsole_Execution", null, detail.UserName,
                                           detail.Location, detail.Product, detail.Layer);

            // create perf logger
            SLogger.WritePerformance(detail);

            SLogger.WriteDiagnostics(detail);

            SLogger.WriteUsage(detail);

            try
            {
                var ex = new Exception("Something bad happened.");
                ex.Data.Add("input param", "nothing to see here");
                throw ex;
            } catch (Exception ex)
            {
                SLogger.WriteError(GetLogDetail("", ex));
            }

            _perfTracker.Stop();
        }
Ejemplo n.º 4
0
 protected override void OnUnload(EventArgs e)
 {
     base.OnUnload(e);
     if (Tracker != null)
     {
         Tracker.Stop();
     }
 }
Ejemplo n.º 5
0
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            PerfTracker stopwatch = (PerfTracker)filterContext.HttpContext.Items["Stopwatch"];

            if (stopwatch != null)
            {
                stopwatch.Stop();
            }
        }
Ejemplo n.º 6
0
        private void btnGet_Click(object sender, RoutedEventArgs e)
        {
            var tracker  = new PerfTracker("getting all todos");
            var ItemList = new List <ToDoItem>();

            using (var svc = new ServiceClient())
                ItemList = svc.GetToDoList();
            LbTodoItems.ItemsSource = ItemList;
            tracker.Stop();
        }
Ejemplo n.º 7
0
        public void AfterCall(string operationName, object[] outputs,
                              object returnValue, object correlationState)
        {
            PerfTracker perfTracker = correlationState as PerfTracker;

            if (perfTracker == null)
            {
                return;
            }

            perfTracker.Stop();
        }
Ejemplo n.º 8
0
        public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
        {
            try
            {
                PerfTracker perfTracker = actionExecutedContext.Request.Properties["PerfTracker"]
                                          as PerfTracker;

                if (perfTracker != null)
                {
                    perfTracker.Stop();
                }
            }
            catch (Exception)
            {
                // ignoring logging exceptions -- don't want an API call to fail
                // if we run into logging problems.
            }
        }
Ejemplo n.º 9
0
 public void OnActionExecuted(ActionExecutedContext context)
 {
     _tracker?.Stop();
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            var fd = GetFlogDetail("starting application", null);

            Flogger.WriteDiagnostic(fd);

            var tracker = new PerfTracker("FloggerConsole_Execution", "", fd.UserName,
                                          fd.Location, fd.Product, fd.Layer);

            //try
            //{
            //    var ex = new Exception("Something bad has happened!");
            //    ex.Data.Add("input param", "nothing to see here");
            //    throw ex;
            //}
            //catch (Exception ex)
            //{
            //    fd = GetFlogDetail("", ex);
            //    Flogger.WriteError(fd);
            //}
            var connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();

            using (var db = new SqlConnection(connStr))
            {
                db.Open();
                try
                {
                    //RAW ADO.NET
                    //var rawAdoSp = new SqlCommand("CreateNewCustomer", db)
                    //{
                    //    CommandType = System.Data.CommandType.StoredProcedure
                    //};
                    //rawAdoSp.Parameters.Add(new SqlParameter("@Name", "waytoolongforitsowngood"));
                    //rawAdoSp.Parameters.Add(new SqlParameter("@TotalPurchases", 12000));
                    //rawAdoSp.Parameters.Add(new SqlParameter("@TotalReturns", 100.50M));
                    //rawAdoSp.ExecuteNonQuery();
                    var sp = new Sproc(db, "CreateNewCustomer");
                    sp.SetParam("@Name", "waytoolongforitsowngood");
                    sp.SetParam("@TotalPurchases", 12000);
                    sp.SetParam("@TotalReturns", 100.50M);
                    sp.ExecNonQuery();
                }
                catch (Exception ex)
                {
                    var efd = GetFlogDetail("", ex);
                    Flogger.WriteError(efd);
                }

                try
                {
                    // Dapper
                    //db.Execute("CreateNewCustomer", new
                    //{
                    //    Name = "dappernametoolongtowork",
                    //    TotalPurchases = 12000,
                    //    TotalReturns = 100.50M
                    //}, commandType: System.Data.CommandType.StoredProcedure);
                    // Wrapped Dapper
                    db.DapperProcNonQuery("CreateNewCustomer", new
                    {
                        Name           = "dappernametoolongtowork",
                        TotalPurchases = 12000,
                        TotalReturns   = 100.50M
                    });
                }
                catch (Exception ex)
                {
                    var efd = GetFlogDetail("", ex);
                    Flogger.WriteError(efd);
                }
            }
            var ctx = new CustomerDbContext();

            try
            {
                // Entity Framework
                var name           = new SqlParameter("@Name", "waytoolongforitsowngood");
                var totalPurchases = new SqlParameter("@TotalPurchases", 12000);
                var totalReturns   = new SqlParameter("@TotalReturns", 100.50M);
                ctx.Database.ExecuteSqlCommand("EXEC dbo.CreateNewCustomer @Name, @TotalPurchases, @TotalReturns",
                                               name, totalPurchases, totalReturns);
            }
            catch (Exception ex)
            {
                var efd = GetFlogDetail("", ex);
                Flogger.WriteError(efd);
            }

            var customers = ctx.Customers.ToList();

            fd = GetFlogDetail($"{customers.Count} customers in the database", null);
            Flogger.WriteDiagnostic(fd);


            fd = GetFlogDetail("used flogging console", null);
            Flogger.WriteUsage(fd);

            fd = GetFlogDetail("stopping app", null);
            Flogger.WriteDiagnostic(fd);

            tracker.Stop();
        }