本文整理汇总了C#中Microsoft.ApplicationInsights.TelemetryClient类的典型用法代码示例。如果您正苦于以下问题:C# TelemetryClient类的具体用法?C# TelemetryClient怎么用?C# TelemetryClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TelemetryClient类属于Microsoft.ApplicationInsights命名空间,在下文中一共展示了TelemetryClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: kameraBtn_Click
private async void kameraBtn_Click(object sender, RoutedEventArgs e)
{
ApplicationView.GetForCurrentView().TitleBar.BackgroundColor = Colors.Red; // Uygulamanın title barı kırmızı olur
ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false; // Ekran screen shoot alınamaz.
var client = new TelemetryClient();
client.TrackEvent("ResimCekButonunaTiklandi");
var camera = new CameraCaptureUI();
camera.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
camera.PhotoSettings.AllowCropping = true;
var file = await camera.CaptureFileAsync(CameraCaptureUIMode.Photo);
// resmi azure'a upload etmek için önce WindowsAzure.Storage 'ı nugetten ekle
// var acount= CloudStorageAccount.Parse("");
// var blobClient = account.CreateCloudBlobClient();
// var folder = blobClient.GetBlockBlobReference("images");
// burada azure'da blob'un içinde images klasorunde profile.jpg adında bir alan oluşturup çekilen fotoğraf buraya upload edilir.
// var blobFile = folder.GetBlockBlobReference("profile.jpg");
// blobFile.UploadFromFileAsync(file);
}
开发者ID:emresevinc,项目名称:WindowsApp,代码行数:25,代码来源:MainPage.xaml.cs
示例2: Application_Error
protected void Application_Error(object sender, EventArgs e)
{
TelemetryClient telemetry = new TelemetryClient();
var exception = Server.GetLastError();
while (exception.InnerException != null)
exception = exception.InnerException;
string exceptionType = exception.GetType().ToString();
string exceptionMessage = exception.Message;
string stackTrace = exception.StackTrace;
switch( exceptionType )
{
case "System.Data.SqlClient.SqlException" :
ErrorEvent.Log.DatabaseError( exceptionType, exceptionMessage, stackTrace);
break;
case "MvcMusicStore.Proxy.ServiceCallException":
string serviceUrl = ((ServiceCallException)exception).ServiceUrl;
ErrorEvent.Log.ServiceCallError(exceptionType, exceptionMessage, stackTrace, serviceUrl);
break;
default:
ErrorEvent.Log.ExcepcionNoManejada(exceptionType, exceptionMessage, stackTrace);
break;
}
//Server.ClearError();
}
开发者ID:dmossberg,项目名称:MusicStoreMvcSource,代码行数:27,代码来源:Global.asax.cs
示例3: App
public App()
{
TelemetryConfiguration.Active.InstrumentationKey = "5afcb70e-e5b7-41c5-9e57-aa6fb9f08c2a";
Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
Microsoft.ApplicationInsights.WindowsCollectors.Session |
Microsoft.ApplicationInsights.WindowsCollectors.PageView |
Microsoft.ApplicationInsights.WindowsCollectors.UnhandledException
);
InitializeComponent();
SplashFactory = (e) => new Views.Splash(e);
#region TelemetryClient Init
Telemetry = new TelemetryClient();
#endregion
MobileService =
new MobileServiceClient(
"https://petrolheadappuwp.azurewebsites.net"
);
#region App settings
var _settings = SettingsService.Instance;
RequestedTheme = _settings.AppTheme;
CacheMaxDuration = _settings.CacheMaxDuration;
ShowShellBackButton = _settings.UseShellBackButton;
#endregion
}
开发者ID:SupernovaApps,项目名称:PetrolheadUWP,代码行数:28,代码来源:App.xaml.cs
示例4: ApplicationInsightsSink
/// <summary>
/// Construct a sink that saves logs to the Application Insights account.
/// </summary>
/// <param name="telemetryClient">Required Application Insights telemetryClient.</param>
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
/// <exception cref="ArgumentNullException">telemetryClient</exception>
/// <exception cref="System.ArgumentNullException">telemetryClient</exception>
public ApplicationInsightsSink(TelemetryClient telemetryClient, IFormatProvider formatProvider = null)
{
if (telemetryClient == null) throw new ArgumentNullException("telemetryClient");
_telemetryClient = telemetryClient;
_formatProvider = formatProvider;
}
开发者ID:alexvaluyskiy,项目名称:serilog-sinks-applicationinsights,代码行数:14,代码来源:ApplicationInsightsSink.cs
示例5: SendMessage
public static bool SendMessage(ContactAttempt contactAttempt)
{
var telemetry = new TelemetryClient();
bool success;
try
{
var contactInfo = _contactInfoRepository.GetContactInfo(contactAttempt.ProfileId);
MailMessage mailMessage = new MailMessage(contactAttempt.EmailAddress, contactInfo.EmailAddress, contactAttempt.Subject, contactAttempt.Message);
var client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["MailUserName"], ConfigurationManager.AppSettings["MailPassword"]);
client.Send(mailMessage);
telemetry.TrackEvent("EmailSent", GetEmailSentTrackingProperties(contactAttempt, contactInfo));
success = true;
}
catch(Exception ex)
{
telemetry.TrackException(ex);
success = false;
}
return success;
}
开发者ID:michaelquinn5280,项目名称:Portfolio,代码行数:25,代码来源:MailHelper.cs
示例6: HtmlToShortPlainTextConverter
public HtmlToShortPlainTextConverter()
{
if (!DesignMode.DesignModeEnabled)
{
_telemetryClient = ServiceLocator.Current.GetInstance<TelemetryClient>();
}
}
开发者ID:valeronm,项目名称:handyNews,代码行数:7,代码来源:HtmlToShortPlainTextConverter.cs
示例7: InitializeTelemetry
private void InitializeTelemetry()
{
try
{
_client = new TelemetryClient();
_client.InstrumentationKey = InstrumentationKey;
_client.Context.Session.Id = Guid.NewGuid().ToString();
_client.Context.Device.OperatingSystem = RuntimeEnvironment.OperatingSystem;
_commonProperties = new Dictionary<string, string>();
_commonProperties.Add(OSVersion, RuntimeEnvironment.OperatingSystemVersion);
_commonProperties.Add(OSPlatform, RuntimeEnvironment.OperatingSystemPlatform.ToString());
_commonProperties.Add(RuntimeId, RuntimeEnvironment.GetRuntimeIdentifier());
_commonProperties.Add(ProductVersion, Product.Version);
_commonProperties.Add(TelemetryProfile, Environment.GetEnvironmentVariable(TelemetryProfileEnvironmentVariable));
_commonMeasurements = new Dictionary<string, double>();
}
catch (Exception)
{
_client = null;
// we dont want to fail the tool if telemetry fails.
Debug.Fail("Exception during telemetry initialization");
}
}
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:25,代码来源:Telemetry.cs
示例8: BuildTelemetryClient
static BuildTelemetryClient()
{
TelemetryConfiguration.Active.TelemetryChannel.EndpointAddress = Properties.Resources.TelemetryEndpoint;
TelemetryConfiguration.Active.InstrumentationKey = Properties.Resources.AppInsightsInstrumentationKey;
_telemetryClient = new TelemetryClient();
try
{
/*
* Explicitly open the registry as 64-bit so the values under SQMClient show up on 64-bit OS.
* On 32-bit OS this will not have any effect and the values under SQMClient will show up.
*/
RegistryKey sqmClientKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
sqmClientKey = sqmClientKey.OpenSubKey(SqmClientRegKey, false);
if (sqmClientKey != null)
{
string machineId = (string)sqmClientKey.GetValue(SqmMachineIdRegValue, string.Empty);
if (!string.IsNullOrEmpty(machineId))
{
Guid parsedMachineId = Guid.Empty;
Guid.TryParse(machineId, out parsedMachineId);
_machineId = parsedMachineId.ToString();
}
}
else
{
_machineId = Guid.Empty.ToString();
}
}
catch (Exception)
{
_machineId = Guid.Empty.ToString();
}
}
开发者ID:alexdrenea,项目名称:WinObjC,代码行数:34,代码来源:BuildTelemetryClient.cs
示例9: App
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
WindowsAppInitializer.InitializeAsync()
.ContinueWith(
task =>
{
TelemetryConfiguration.Active.TelemetryInitializers.Add(new UwpDeviceTelemetryInitializer());
})
.ContinueWith(task => { Telemetry = new TelemetryClient(); });
this.InitializeComponent();
this.Suspending += this.OnSuspending;
this.Resuming += this.OnResuming;
this.UnhandledException += this.App_UnhandledException;
if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
HardwareButtons.BackPressed += this.HardwareButtons_BackPressed;
}
try
{
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
}
catch (Exception)
{
// on device which doesn't have it... (core)
}
}
开发者ID:CRDeveloper,项目名称:virtual-shields-universal,代码行数:33,代码来源:App.xaml.cs
示例10: IsEnabledReturnsTrueIfTelemetryTrackingIsEnabledInConfiguration
public void IsEnabledReturnsTrueIfTelemetryTrackingIsEnabledInConfiguration()
{
var configuration = new TelemetryConfiguration { DisableTelemetry = false };
var client = new TelemetryClient(configuration);
Assert.True(client.IsEnabled());
}
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:7,代码来源:TelemetryClientTest.cs
示例11: App
/// <summary>
/// Initializes the singleton instance of the <see cref="App"/> class. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new TelemetryClient();
this.InitializeComponent();
this.Suspending += this.OnSuspending;
}
开发者ID:Jinwenxin,项目名称:ApplicationInsights-Home,代码行数:11,代码来源:App.xaml.cs
示例12: App
public App()
{
TelemetryClient = new TelemetryClient();
InitializeComponent();
Suspending += OnSuspending;
}
开发者ID:modulexcite,项目名称:events,代码行数:7,代码来源:App.xaml.cs
示例13: EvalOperation
internal EvalOperation(OnlineTrainerSettingsInternal settings)
{
this.telemetry = new TelemetryClient();
// evaluation pipeline
this.evalEventHubClient = EventHubClient.CreateFromConnectionString(settings.EvalEventHubConnectionString);
this.evalBlock = new TransformManyBlock<object, EvalData>(
(Func<object, IEnumerable<EvalData>>)this.OfflineEvaluate,
new ExecutionDataflowBlockOptions
{
MaxDegreeOfParallelism = 4,
BoundedCapacity = 1024
});
this.evalBlock.Completion.ContinueWith(t =>
{
this.telemetry.TrackTrace($"Stage 3 - Evaluation pipeline completed: {t.Status}");
if (t.IsFaulted)
this.telemetry.TrackException(t.Exception);
});
// batch output together to match EventHub throughput by maintaining maximum latency of 5 seconds
this.evalBlockDisposable = this.evalBlock.AsObservable()
.GroupBy(k => k.PolicyName)
.Select(g =>
g.Window(TimeSpan.FromSeconds(5))
.Select(w => w.Buffer(245 * 1024, e => Encoding.UTF8.GetByteCount(e.JSON)))
.SelectMany(w => w)
.Subscribe(this.UploadEvaluation))
.Publish()
.Connect();
}
开发者ID:XkhldY,项目名称:vowpal_wabbit,代码行数:33,代码来源:EvalOperation.cs
示例14: CreateClient
private static TelemetryClient CreateClient(string clientName, string instrumentationKey,
Assembly sourceAssembly)
{
if (_clientsAndConfigs.ContainsKey(clientName))
{
throw new ArgumentException(
$"A client already exists with name \"{clientName}\". Use GetClient() to retrieve it.",
nameof(clientName));
}
if (_clientsAndConfigs.Any(c => c.Value.Item1.InstrumentationKey.Equals(instrumentationKey, StringComparison.OrdinalIgnoreCase)))
{
throw new ArgumentException(
"A client already exists with the given instrumentation key.", nameof(instrumentationKey));
}
var config = TelemetryConfiguration.CreateDefault();
var client = new TelemetryClient(config);
ConfigureApplication(instrumentationKey, client, config,
new TelemetryInitializer(sourceAssembly));
_clientsAndConfigs.Add(clientName, Tuple.Create(client, config));
return client;
}
开发者ID:madhon,项目名称:WinFormsAppInsights,代码行数:25,代码来源:Telemetry.cs
示例15: HeroPhotoController
/// <summary>
/// Controller for hero photo operations.
/// </summary>
/// <param name="repository">Data layer.</param>
/// <param name="telemetryClient">Telemetry client.</param>
/// <param name="userRegistrationReferenceProvider">The user registration reference provider.</param>
public HeroPhotoController(IRepository repository, TelemetryClient telemetryClient,
IUserRegistrationReferenceProvider userRegistrationReferenceProvider)
: base(userRegistrationReferenceProvider)
{
_repository = repository;
_telemetryClient = telemetryClient;
}
开发者ID:Microsoft,项目名称:Appsample-Photosharing,代码行数:13,代码来源:HeroPhotoController.cs
示例16: OnStart
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 128;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("APPINSIGHTS_INSTRUMENTATIONKEY");
// TODO: disable
// TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
this.telemetry = new TelemetryClient();
this.telemetry.TrackTrace("WorkerRole starting", SeverityLevel.Information);
try
{
this.trainProcesserHost = new LearnEventProcessorHost();
this.settingsWatcher = new OnlineTrainerSettingsWatcher(this.trainProcesserHost);
this.StartRESTAdminEndpoint();
}
catch (Exception e)
{
this.telemetry.TrackException(e);
// still start to give AppInsights a chance to log
}
return result;
}
开发者ID:gramhagen,项目名称:vowpal_wabbit,代码行数:33,代码来源:WorkerRole.cs
示例17: Initialize
/// <summary>
/// Initializes the telemetry client.
/// </summary>
public static void Initialize(IServiceProvider serviceProvider, string version, string telemetryKey)
{
if (_telemetry != null)
throw new NotSupportedException("The telemetry client is already initialized");
var dte = (DTE2)serviceProvider.GetService(typeof(DTE));
_telemetry = new TelemetryClient();
_telemetry.Context.Session.Id = Guid.NewGuid().ToString();
_telemetry.Context.Device.Model = dte.Edition;
_telemetry.InstrumentationKey = telemetryKey;
_telemetry.Context.Component.Version = version;
byte[] enc = Encoding.UTF8.GetBytes(Environment.UserName + Environment.MachineName);
using (var crypto = new MD5CryptoServiceProvider())
{
byte[] hash = crypto.ComputeHash(enc);
_telemetry.Context.User.Id = Convert.ToBase64String(hash);
}
_events = dte.Events.DTEEvents;
_events.OnBeginShutdown += delegate { _telemetry.Flush(); };
Enabled = true;
}
开发者ID:modulexcite,项目名称:MicrosoftBandTools,代码行数:28,代码来源:Telemetry.cs
示例18: Start
public static void Start()
{
if (null == s_telemetryClient)
{
s_telemetryClient = new TelemetryClient();
}
}
开发者ID:codekaizen,项目名称:internetradio,代码行数:7,代码来源:TelemetryManager.cs
示例19: OnException
public override void OnException(ExceptionContext filterContext)
{
if (filterContext != null && filterContext.HttpContext != null && filterContext.Exception != null)
{
//If customError is Off, then AI HTTPModule will report the exception
if (filterContext.HttpContext.IsCustomErrorEnabled)
{
string email;
try
{
email = filterContext.HttpContext.User.Identity.Name;
}
catch
{
email = "unknown";
}
var properties = new Dictionary<string, string>();
properties.Add("AzureDayUserEmail", email);
// Note: A single instance of telemetry client is sufficient to track multiple telemetry items.
var ai = new TelemetryClient();
ai.TrackException(filterContext.Exception, properties);
}
}
base.OnException(filterContext);
}
开发者ID:AzureDay,项目名称:2016-WebSite,代码行数:27,代码来源:ApplicationInsightHandleErrorAttribute.cs
示例20: MfTargetDevice
public MfTargetDevice(MFPortDefinition port, MFDevice device)
{
_port = port;
_device = device;
_tc = App.Kernel.Get<TelemetryClient>();
Task.Run(() => InitializeAsync());
}
开发者ID:scout119,项目名称:ScratchDotNet,代码行数:7,代码来源:MfTargetDevice.cs
注:本文中的Microsoft.ApplicationInsights.TelemetryClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论