当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法代码示例

本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法的具体用法?C# Microsoft.ApplicationInsights.TelemetryClient.TrackEvent怎么用?C# Microsoft.ApplicationInsights.TelemetryClient.TrackEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.ApplicationInsights.TelemetryClient的用法示例。


在下文中一共展示了Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: updateWith10DayData

 private void updateWith10DayData(string response)
 {
     var json = JObject.Parse(response);
     JToken forecastToken;
     if (!json.TryGetValue("forecast", out forecastToken))
     {
         var tc = new Microsoft.ApplicationInsights.TelemetryClient();
         var properties = new Dictionary<String, string> { { "response", response } };
         tc.TrackEvent($"Unexpected response in {nameof(updateWith10DayData)}", properties);
         return;
     }
     var allDaily = forecastToken["simpleforecast"]["forecastday"].Children();
     var dailyForecast = new List<WeatherDetailsModel>();
     foreach (var daily in allDaily.Take(10))
     {
         var rawEpoch = Int64.Parse(daily["date"]["epoch"].ToString());
         var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
         var forecast = new WeatherDetailsModel()
         {
             Conditions = daily["conditions"].ToString(),
             TemperatureHigh = Int32.Parse(daily["high"]["celsius"].ToString()),
             TemperatureLow = Int32.Parse(daily["low"]["celsius"].ToString()),
             Rainfall = Int32.Parse(daily["qpf_allday"]["mm"].ToString()),
             Snowfall = Int32.Parse(daily["snow_allday"]["cm"].ToString()),
             Time = epoch.DateTime,
         };
         dailyForecast.Add(forecast);
     }
     DailyForecast = dailyForecast;
 }
开发者ID:AmadeusW,项目名称:Mirror,代码行数:30,代码来源:WeatherModel_wunderground.cs

示例2: Index

        //
        // GET: /Home/

        public async Task<ActionResult> Index()
        {
            // Get most popular albums
            var albums = await GetTopSellingAlbums(6);
            //var albums = GetTopSellingAlbums(6);

            // Trigger some good old ADO code 
            var albumCount = GetTotalAlbumns(); 
            Trace.Write(string.Format("Total number of Albums = {0} and Albums with 'The' = {1}", albumCount.Item1, albumCount.Item2));

            var telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();

            //Sample Trace telemetry
            TraceTelemetry traceSample = new TraceTelemetry();
            traceSample.Message = "Slow response - database";
            traceSample.SeverityLevel = SeverityLevel.Warning;
            telemetryClient.TrackTrace(traceSample);

            //Sample event telemetry
            var properties = new Dictionary<string, string> { { "Property 1",string.Format("Album Count {0}" ,albumCount.Item1) } };
            var measurements = new Dictionary<string, double> { { "Sample Meassurement", albumCount.Item1 } };
            telemetryClient.TrackEvent("Top Selling Albums", properties, measurements);

            //Sample exception telemetry
            try
            {
                albumCount = null;
                int count=albumCount.Item1;
            }
            catch (Exception ex)
            {
                telemetryClient.TrackException(ex, properties, measurements);
            }

            //Obtains the ip address from the request
            var request = new RequestTelemetry();
            request.Url = HttpContext.Request.Url;
            request.Duration = System.TimeSpan.FromMilliseconds(100);
            request.Success = false;
            request.Name = "TEST REQUEST " + request.Name;
            telemetryClient.TrackRequest(request);

            return View(albums);
        }
开发者ID:pablodam20,项目名称:Glimpse.ApplicationInsights,代码行数:47,代码来源:HomeController.cs

示例3: GetSasToken

        public string GetSasToken(string deviceId)
        {

            string ns = WebApiApplication.ehWebConsumerGroup.eventHubNamespace;
            string hubName = WebApiApplication.ehWebConsumerGroup.eventHubPath;
            string keyName = WebApiApplication.ehWebConsumerGroup.SendKeyName;
            string key = WebApiApplication.ehWebConsumerGroup.SendKeyValue;

            int TTLmins = 60 * 24;

            if (deviceId == "")
                return "";


             TimeSpan ttl = new TimeSpan(0, TTLmins, 0);

            var sas = CreateForHttpSender(keyName, key, ns, hubName, deviceId, ttl);

            // add app insight
            var tc = new Microsoft.ApplicationInsights.TelemetryClient();
            tc.TrackEvent("SasToken dispensed");
            
            return sas;
        }
开发者ID:amykatenicho,项目名称:ms-band-azure,代码行数:24,代码来源:ValuesController.cs

示例4: Execute

        public static bool Execute(string[] args, Stream outputStream)
        {
            var sessionId = Guid.NewGuid().ToString();
            var machineId = getMachineId();
            // Create AppInsights telemetry client to track app usage
            TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
            TelemetryClient.Context.User.Id = machineId;
            TelemetryClient.Context.Session.Id = sessionId;

            Assembly assembly = Assembly.GetAssembly(typeof(DeploymentWorker));
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
            var version = fileVersionInfo.ProductVersion;
            TelemetryClient.TrackEvent("DeployStart", new Dictionary<string, string>()
            {
                { "AppVersion", version }
            });

            var worker = new DeploymentWorker(outputStream);
            if (!worker.argsHandler.HandleCommandLineArgs(args))
            {
                TelemetryClient.TrackEvent("DeployFailed_IncorrectArgs", new Dictionary<string, string>() { });
                TelemetryClient.Flush();
                return false;
            }

            worker.OutputMessage(Resource.DeploymentWorker_Starting);
            var taskResult = worker.CreateAndDeployApp();
            if (taskResult)
            {
                TelemetryClient.TrackEvent("DeploySucceeded", new Dictionary<string, string>() { });
            }
            else
            {
                TelemetryClient.TrackEvent("DeployFailed", new Dictionary<string, string>() { });
            }

            TelemetryClient.Flush();
            return taskResult;
        }
开发者ID:ms-iot,项目名称:iot-utilities,代码行数:39,代码来源:DeploymentWorker.cs

示例5: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            var tc = new Microsoft.ApplicationInsights.TelemetryClient();

            var navigation = new NavigationController(launchScreenCallback);
            CoreWindow.GetForCurrentThread().KeyDown += navigation.GlobalKeyDown;

            await SettingsController.LoadSettings();

            try
            {
                var clockModel = new ClockModel();
                Task.Run(() => clockModel.Update());
                (Resources["clockViewModel"] as ClockViewModel).Initialize(clockModel);
                TimerController.RegisterModel(clockModel);
                navigation.RegisterView(typeof(ClockView));
                clockModel.NightFallDelegate += TimeOfDayChangedHandler;
            }
            catch (Exception ex)
            {
                var properties = new Dictionary<String, string> { { "Module", "Clock" } };
                tc.TrackException(ex, properties);
                System.Diagnostics.Debugger.Break();
            }

            try
            { 
                var weatherModel = new WeatherModel_wunderground();
                Task.Run(() => weatherModel.Update());
                TimerController.RegisterModel(weatherModel);
                (Resources["weatherThisWeekViewModel"] as WeatherThisWeekViewModel).Initialize(weatherModel);
                (Resources["weatherTodayViewModel"] as WeatherTodayViewModel).Initialize(weatherModel);
                navigation.RegisterView(typeof(WeatherThisWeekView));
                navigation.RegisterView(typeof(WeatherTodayView));
            }
            catch (Exception ex)
            {
                var properties = new Dictionary<String, string> { { "Module", "Weather" } };
                tc.TrackException(ex, properties);
                System.Diagnostics.Debugger.Break();
            }

            try
            { 
                var transitModel = new TransitModel_translink();
                Task.Run(() => transitModel.Update());
                TimerController.RegisterModel(transitModel);
                (Resources["transitViewModel"] as TransitViewModel).Initialize(transitModel);
                TimerController.RegisterViewModel((Resources["transitViewModel"] as TransitViewModel));
                navigation.RegisterView(typeof(TransitView));
            }
            catch (Exception ex)
            {
                var properties = new Dictionary<String, string> { { "Module", "Transit" } };
                tc.TrackException(ex, properties);
                System.Diagnostics.Debugger.Break();
            }

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new ThemeAwareFrame(ElementTheme.Light);

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(ClockView), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
            tc.TrackEvent("Smart Mirror has loaded.");
//.........这里部分代码省略.........
开发者ID:AmadeusW,项目名称:Mirror,代码行数:101,代码来源:App.xaml.cs

示例6: updateAstronomy

 private void updateAstronomy(string response)
 {
     var json = JObject.Parse(response);
     JToken astronomyRoot;
     if (!json.TryGetValue("moon_phase", out astronomyRoot))
     {
         var tc = new Microsoft.ApplicationInsights.TelemetryClient();
         var properties = new Dictionary<String, string> { { "response", response } };
         tc.TrackEvent($"Unexpected response in {nameof(updateAstronomy)}", properties);
         return;
     }
     var rawSunrise = astronomyRoot["sunrise"];
     var rawSunset = astronomyRoot["sunset"];
     // Date doesn't matter, we only care about hours and minutes
     Sunrise = DateTime.Parse(rawSunrise["hour"]+":"+ rawSunrise["minute"]);
     Sunset = DateTime.Parse(rawSunset["hour"] + ":" + rawSunset["minute"]);
 }
开发者ID:AmadeusW,项目名称:Mirror,代码行数:17,代码来源:WeatherModel_wunderground.cs

示例7: updateWithHourlyData

 private void updateWithHourlyData(string response)
 {
     var json = JObject.Parse(response);
     JToken allHourly;
     if (!json.TryGetValue("hourly_forecast", out allHourly))
     {
         var tc = new Microsoft.ApplicationInsights.TelemetryClient();
         var properties = new Dictionary<String, string> { { "response", response } };
         tc.TrackEvent($"Unexpected response in {nameof(updateWithHourlyData)}", properties);
         return;
     }
     var hourlyForecast = new List<WeatherDetailsModel>();
     foreach (var hourly in allHourly.Take(24))
     {
         var rawEpoch = Int64.Parse(hourly["FCTTIME"]["epoch"].ToString());
         var epoch = DateTimeOffset.FromUnixTimeSeconds(rawEpoch);
         var forecast = new WeatherDetailsModel()
         {
             Conditions = hourly["condition"].ToString(),
             Temperature = Int32.Parse(hourly["temp"]["metric"].ToString()),
             Rainfall = Int32.Parse(hourly["qpf"]["metric"].ToString()),
             Snowfall = Int32.Parse(hourly["snow"]["metric"].ToString()),
             Time = epoch.DateTime,
         };
         hourlyForecast.Add(forecast);
     }
     HourlyForecast = hourlyForecast;
 }
开发者ID:AmadeusW,项目名称:Mirror,代码行数:28,代码来源:WeatherModel_wunderground.cs


注:本文中的Microsoft.ApplicationInsights.TelemetryClient.TrackEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。