Exemple #1
0
        /// <summary>
        /// Post-Request processing
        /// </summary>
        /// <param name="context">type: IOwinContext</param>
        private void EndRequest(IOwinContext context)
        {
            if (HttpContext.Current == null)
            {
                return;
            }

            var startTime = ItemDecorator.GetInspectorInstance()[ItemDecorator.RequestStartTime];

            if (startTime != null
                //// ignore non-user pings
                && TelemetryState.IsTelemetryEnabledUserAgent()
                //// ignore requests to specific paths
                && TelemetryState.IsTelemetryEnabledRequestPath()
                //// ignore requests to specific extensions
                && TelemetryState.IsTelemetryEnabledRequestExtension()
                //// make sure the portal is configured
                && this.IsPortalConfigured())
            {
                var requestStartTime = (DateTime)startTime;
                var elapsedTime      = DateTime.UtcNow - requestStartTime;
                MdmMetrics.RequestExecutionTimeMetric.LogValue((long)elapsedTime.TotalMilliseconds);

                var ag = PerformanceAggregateLogger.GetPerformanceAggregate();
                if (ag != null)
                {
                    PerformanceEventSource.Log.PerformanceAggregate(ag, elapsedTime);
                }
            }
        }
Exemple #2
0
 private static void DecreaseSellInValue(ItemDecorator item)
 {
     if (item.Name != SulfurasHandOfRagnaros)
     {
         item.SellIn = item.SellIn - 1;
     }
 }
Exemple #3
0
        protected string ElapsedTime()
        {
            try
            {
                if (this.HttpContext == null)
                {
                    return(string.Empty);
                }

                if (this.OwinContext == null || this.OwinContext.Get <RequestElapsedTimeContext>() == null)
                {
                    var inspector = ItemDecorator.GetInspectorInstance(this.HttpContextBase);
                    var startTime = inspector[ItemDecorator.RequestStartTime];
                    if (startTime != null)
                    {
                        var requestStartTime = (DateTime)startTime;
                        return((DateTime.UtcNow - requestStartTime).TotalMilliseconds.ToString(CultureInfo.InvariantCulture));
                    }

                    return(string.Empty);
                }
                else
                {
                    return(this.OwinContext.Get <RequestElapsedTimeContext>().ElapsedTime().ToString());
                }
            }
            catch
            {
                // eat exception expecting it to possibly happen in scenarios without context
                // i.g., background worker threads
                return(string.Empty);
            }
        }
Exemple #4
0
        public override void Execute()
        {
            Logger.GetLoggerInstance().Info(string.Format("Copying files to new destination using config: {0}\n\n", this.Value));

            var           iterator = new CollectionInterator(SerializationHelper.Deserialize(this.Value));
            ItemDecorator item     = null;

            while ((item = iterator.Next()) != null)
            {
                Logger.GetLoggerInstance().Info(string.Format("Copying {0} ...", item.CurrentPath));

                File.Copy(item.CurrentPath, item.GetNewPath());
            }
        }
Exemple #5
0
        public Item OpenChest(Character character)
        {
            if (character.Item == null)
            {
                int itemIndex = random.Next(3);

                switch (itemIndex)
                {
                case 0:
                    return(new Bow());

                case 1:
                    return(new Sword());

                default:
                    return(new Shield());
                }
            }
            else
            {
                return(ItemDecorator.GetDamage(character.Item));
            }
        }
Exemple #6
0
 /// <summary>
 /// Pre-Request processing
 /// </summary>
 /// <param name="context">type: IOwinContext</param>
 private void BeginRequest(IOwinContext context)
 {
     HeaderDecorator.GetInstance().Decorate();
     ItemDecorator.GetInstance().Decorate();
 }