public RaygunEnvironmentMessage() { ProcessorCount = Environment.ProcessorCount; #if !WINRT OSVersion = Environment.OSVersion.VersionString; Architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); Cpu = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER"); WindowBoundsWidth = SystemInformation.VirtualScreen.Height; WindowBoundsHeight = SystemInformation.VirtualScreen.Width; ComputerInfo info = new ComputerInfo(); TotalPhysicalMemory = (ulong)info.TotalPhysicalMemory / 0x100000; // in MB AvailablePhysicalMemory = (ulong)info.AvailablePhysicalMemory / 0x100000; TotalVirtualMemory = info.TotalVirtualMemory / 0x100000; AvailableVirtualMemory = info.AvailableVirtualMemory / 0x100000; Location = CultureInfo.CurrentCulture.DisplayName; OSVersion = info.OSVersion; GetDiskSpace(); //GetCpu(); #else //WindowBoundsHeight = Windows.UI.Xaml.Window.Current.Bounds.Height; //WindowBoundsWidth = Windows.UI.Xaml.Window.Current.Bounds.Width; PackageVersion = string.Format("{0}.{1}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor); Cpu = Package.Current.Id.Architecture.ToString(); ResolutionScale = DisplayProperties.ResolutionScale.ToString(); CurrentOrientation = DisplayProperties.CurrentOrientation.ToString(); Location = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion; SYSTEM_INFO systemInfo = new SYSTEM_INFO(); RaygunSystemInfoWrapper.GetNativeSystemInfo(ref systemInfo); Architecture = systemInfo.wProcessorArchitecture.ToString(); #endif }
public static RaygunEnvironmentMessage Build() { RaygunEnvironmentMessage message = new RaygunEnvironmentMessage(); try { if (Windows.UI.Xaml.Window.Current != null) { message.WindowBoundsHeight = Windows.UI.Xaml.Window.Current.Bounds.Height; message.WindowBoundsWidth = Windows.UI.Xaml.Window.Current.Bounds.Width; } message.ResolutionScale = DisplayProperties.ResolutionScale.ToString(); message.CurrentOrientation = DisplayProperties.CurrentOrientation.ToString(); message.ViewState = ApplicationView.Value.ToString(); } catch (Exception ex) { Debug.WriteLine("Error retrieving window info: {0}", ex.Message); } try { DateTime now = DateTime.Now; message.UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours; message.Locale = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion; } catch (Exception ex) { Debug.WriteLine("Error retrieving time and locale: {0}", ex.Message); } try { message.Cpu = Package.Current.Id.Architecture.ToString(); SYSTEM_INFO systemInfo = new SYSTEM_INFO(); RaygunSystemInfoWrapper.GetNativeSystemInfo(ref systemInfo); message.Architecture = ((PROCESSOR_ARCHITECTURE)systemInfo.wProcessorArchitecture).ToString(); message.ProcessorCount = (int)systemInfo.dwNumberOfProcessors; message.OSVersion = GetOSVersion(); } catch (Exception ex) { Debug.WriteLine("Error retrieving device info: {0}", ex.Message); } return message; }
public RaygunEnvironmentMessage() { WindowBoundsHeight = Windows.UI.Xaml.Window.Current.Bounds.Height; WindowBoundsWidth = Windows.UI.Xaml.Window.Current.Bounds.Width; PackageVersion = string.Format("{0}.{1}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor); Cpu = Package.Current.Id.Architecture.ToString(); ResolutionScale = DisplayProperties.ResolutionScale.ToString(); CurrentOrientation = DisplayProperties.CurrentOrientation.ToString(); Locale = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion; DateTime now = DateTime.Now; UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours; SYSTEM_INFO systemInfo = new SYSTEM_INFO(); RaygunSystemInfoWrapper.GetNativeSystemInfo(ref systemInfo); Architecture = ((PROCESSOR_ARCHITECTURE)systemInfo.wProcessorArchitecture).ToString(); ProcessorCount = (int)systemInfo.dwNumberOfProcessors; ViewState = ApplicationView.Value.ToString(); }
public RaygunEnvironmentMessage() { #if WINRT //WindowBoundsHeight = Windows.UI.Xaml.Window.Current.Bounds.Height; //WindowBoundsWidth = Windows.UI.Xaml.Window.Current.Bounds.Width; PackageVersion = string.Format("{0}.{1}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor); Cpu = Package.Current.Id.Architecture.ToString(); ResolutionScale = DisplayProperties.ResolutionScale.ToString(); CurrentOrientation = DisplayProperties.CurrentOrientation.ToString(); Location = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion; DateTime now = DateTime.Now; UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours; SYSTEM_INFO systemInfo = new SYSTEM_INFO(); RaygunSystemInfoWrapper.GetNativeSystemInfo(ref systemInfo); Architecture = systemInfo.wProcessorArchitecture.ToString(); #elif WINDOWS_PHONE Locale = CultureInfo.CurrentCulture.DisplayName; OSVersion = Environment.OSVersion.Platform + " " + Environment.OSVersion.Version; object deviceName; DeviceExtendedProperties.TryGetValue("DeviceName", out deviceName); DeviceName = deviceName.ToString(); WindowBoundsWidth = Application.Current.RootVisual.RenderSize.Width; WindowBoundsHeight = Application.Current.RootVisual.RenderSize.Height; DateTime now = DateTime.Now; UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours; PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { CurrentOrientation = frame.Orientation.ToString(); } //ProcessorCount = Environment.ProcessorCount; // TODO: finish other values #elif ANDROID try { Java.Util.TimeZone tz = Java.Util.TimeZone.Default; Java.Util.Date now = new Java.Util.Date(); UtcOffset = tz.GetOffset(now.Time) / 3600000.0; OSVersion = Android.OS.Build.VERSION.Sdk; Locale = CultureInfo.CurrentCulture.DisplayName; var metrics = Resources.System.DisplayMetrics; WindowBoundsWidth = metrics.WidthPixels; WindowBoundsHeight = metrics.HeightPixels; Context context = RaygunClient.Context; if (context != null) { PackageManager manager = context.PackageManager; PackageInfo info = manager.GetPackageInfo(context.PackageName, 0); PackageVersion = info.VersionCode + " / " + info.VersionName; IWindowManager windowManager = context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>(); if (windowManager != null) { Display display = windowManager.DefaultDisplay; if (display != null) { switch (display.Rotation) { case SurfaceOrientation.Rotation0: CurrentOrientation = "Rotation 0 (Portrait)"; break; case SurfaceOrientation.Rotation180: CurrentOrientation = "Rotation 180 (Upside down)"; break; case SurfaceOrientation.Rotation270: CurrentOrientation = "Rotation 270 (Landscape right)"; break; case SurfaceOrientation.Rotation90: CurrentOrientation = "Rotation 90 (Landscape left)"; break; } } } } DeviceName = RaygunClient.DeviceName; Java.Lang.Runtime runtime = Java.Lang.Runtime.GetRuntime(); TotalPhysicalMemory = (ulong)runtime.TotalMemory(); AvailablePhysicalMemory = (ulong)runtime.FreeMemory(); ProcessorCount = runtime.AvailableProcessors(); Architecture = Android.OS.Build.CpuAbi; Model = string.Format("{0} / {1} / {2}", Android.OS.Build.Model, Android.OS.Build.Brand, Android.OS.Build.Manufacturer); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("Error getting environment info {0}", ex.Message)); } #elif IOS UtcOffset = NSTimeZone.LocalTimeZone.GetSecondsFromGMT / 3600.0; OSVersion = UIDevice.CurrentDevice.SystemName + " " + UIDevice.CurrentDevice.SystemVersion; Architecture = GetStringSysCtl(ArchitecturePropertyName); Model = UIDevice.CurrentDevice.Model; ProcessorCount = (int)GetIntSysCtl(ProcessiorCountPropertyName); Locale = CultureInfo.CurrentCulture.DisplayName; UIApplication.SharedApplication.InvokeOnMainThread(() => { WindowBoundsWidth = UIScreen.MainScreen.Bounds.Width; WindowBoundsHeight = UIScreen.MainScreen.Bounds.Height; }); CurrentOrientation = UIDevice.CurrentDevice.Orientation.ToString(); TotalPhysicalMemory = GetIntSysCtl(TotalPhysicalMemoryPropertyName); AvailablePhysicalMemory = GetIntSysCtl(AvailablePhysicalMemoryPropertyName); DeviceName = UIDevice.CurrentDevice.Name; PackageVersion = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleVersion").ToString(); #else WindowBoundsWidth = SystemInformation.VirtualScreen.Height; WindowBoundsHeight = SystemInformation.VirtualScreen.Width; ComputerInfo info = new ComputerInfo(); Locale = CultureInfo.CurrentCulture.DisplayName; DateTime now = DateTime.Now; UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(now).TotalHours; OSVersion = info.OSVersion; if (!RaygunSettings.Settings.MediumTrust) { try { Architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); TotalPhysicalMemory = (ulong)info.TotalPhysicalMemory / 0x100000; // in MB AvailablePhysicalMemory = (ulong)info.AvailablePhysicalMemory / 0x100000; TotalVirtualMemory = info.TotalVirtualMemory / 0x100000; AvailableVirtualMemory = info.AvailableVirtualMemory / 0x100000; GetDiskSpace(); Cpu = GetCpu(); } catch (SecurityException) { System.Diagnostics.Trace.WriteLine("RaygunClient error: couldn't access environment variables. If you are running in Medium Trust, in web.config in RaygunSettings set mediumtrust=\"true\""); } } #endif }
public RaygunEnvironmentMessage() { #if WINRT //WindowBoundsHeight = Windows.UI.Xaml.Window.Current.Bounds.Height; //WindowBoundsWidth = Windows.UI.Xaml.Window.Current.Bounds.Width; PackageVersion = string.Format("{0}.{1}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor); Cpu = Package.Current.Id.Architecture.ToString(); ResolutionScale = DisplayProperties.ResolutionScale.ToString(); CurrentOrientation = DisplayProperties.CurrentOrientation.ToString(); Location = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion; DateTime now = DateTime.Now; UtcOffset = TimeZoneInfo.Local.GetUtcOffset(now).TotalHours; SYSTEM_INFO systemInfo = new SYSTEM_INFO(); RaygunSystemInfoWrapper.GetNativeSystemInfo(ref systemInfo); Architecture = systemInfo.wProcessorArchitecture.ToString(); #elif WINDOWS_PHONE Locale = CultureInfo.CurrentCulture.DisplayName; OSVersion = Environment.OSVersion.Platform + " " + Environment.OSVersion.Version; object deviceName; DeviceExtendedProperties.TryGetValue("DeviceName", out deviceName); DeviceName = deviceName.ToString(); WindowBoundsWidth = Application.Current.RootVisual.RenderSize.Width; WindowBoundsHeight = Application.Current.RootVisual.RenderSize.Height; PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { CurrentOrientation = frame.Orientation.ToString(); } //ProcessorCount = Environment.ProcessorCount; // TODO: finish other values #else WindowBoundsWidth = SystemInformation.VirtualScreen.Height; WindowBoundsHeight = SystemInformation.VirtualScreen.Width; ComputerInfo info = new ComputerInfo(); Locale = CultureInfo.CurrentCulture.DisplayName; DateTime now = DateTime.Now; UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(now).TotalHours; OSVersion = info.OSVersion; if (!RaygunSettings.Settings.MediumTrust) { try { Architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); TotalPhysicalMemory = (ulong)info.TotalPhysicalMemory / 0x100000; // in MB AvailablePhysicalMemory = (ulong)info.AvailablePhysicalMemory / 0x100000; TotalVirtualMemory = info.TotalVirtualMemory / 0x100000; AvailableVirtualMemory = info.AvailableVirtualMemory / 0x100000; GetDiskSpace(); Cpu = GetCpu(); } catch (SecurityException) { System.Diagnostics.Trace.WriteLine("RaygunClient error: couldn't access environment variables. If you are running in Medium Trust, in web.config in RaygunSettings set mediumtrust=\"true\""); } } #endif }
public static extern void GetNativeSystemInfo(ref SYSTEM_INFO systemInfo);