Exemplo n.º 1
0
        public static AppEnvironment GetEnvironment(string appName, string appVersion, string uuid,
            bool basic = false)
        {
            AppEnvironment environment = new AppEnvironment();

            environment.AppName = appName;
            environment.AppVersion = appVersion;

            environment.OsVersion = "Windows NT 6.2";
            environment.PhoneModel = "unknown";
            environment.PhoneManufacturer = "unknown";

            Task.Run(async () => environment.CpuModel = await GetCpu()).Wait();
            environment.CpuBitness = sizeof(long) * 8;

            environment.IsTrial = Windows.ApplicationModel.Store.CurrentApp.LicenseInformation.IsTrial;

            environment.Uid = uuid;

            environment.GeoRegion = Windows.System.UserProfile.GlobalizationPreferences.HomeGeographicRegion;
            environment.Locale = Windows.System.UserProfile.GlobalizationPreferences.Languages[0];

            if (basic)
                return environment;

            environment.WifiOn = 2;
            environment.GpsOn = "unknown";
            environment.CellularData = "unknown";
            environment.Carrier = "unknown";

            environment.ScreenOrientation = Windows.Graphics.Display.DisplayProperties.CurrentOrientation.ToString();
            environment.ScreenDpi = Windows.Graphics.Display.DisplayProperties.LogicalDpi.ToString();
            environment.ScreenWidth = Windows.UI.Xaml.Window.Current.Bounds.Width;
            environment.ScreenHeight = Windows.UI.Xaml.Window.Current.Bounds.Height;

            environment.Rooted = false;

            return environment;
        }
Exemplo n.º 2
0
 public BugSenseEventRequest(AppEnvironment environment, string tag, bool reserved = false)
 {
     ApiVer = G.BUGSENSE_API_VER;
     string tmp = tag.Trim();
     if (!reserved)
     {
         if (tmp[0] == '_')
         {
             char[] tmpc = tmp.ToCharArray();
             tmpc[0] = '-';
             tmp = new string(tmpc);
         }
         tmp = tmp.Replace("|", "-");
     }
     Tag = tmp;
     PhoneModel = environment.PhoneModel;
     PhoneManufacturer = environment.PhoneManufacturer;
     OsVer = environment.OsVersion;
     AppVer = environment.AppVersion;
     Locale = environment.Locale;
     TimeStamp = ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds).ToString();
 }
 public BugSenseRequest(BugSenseEx ex, AppEnvironment environment)
 {
     client = new BugSenseClient();
     request = new BugSenseInternalRequest();
     request.comment = string.IsNullOrEmpty(ex.Comment) ? ex.message : ex.Comment;
     exception = ex;
     this.application_environment = environment;
 }
        internal AppEnvironment GetEnvironment()
        {
            AppEnvironment environment = new AppEnvironment();
            environment.appname = _appName;
            environment.appver = _appVersion;
#if WINDOWS_RT
            // TODO: Currently there is no way to get the OS version
            // even for error logging purposes... which i suspect will
            // change before too long.
            environment.osver = "Windows 8 Metro";
#elif iOS
            environment.osver = UIDevice.CurrentDevice.SystemVersion;
#else
            environment.osver = Environment.OSVersion.Version.ToString();
#endif
            string result = string.Empty;

            object manufacturer;
            
#if WINDOWS_RT
#elif iOS
            result = DeviceIdentifier.Version.ToString();
#else
            //TODO: Find model
            if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))
                result = manufacturer.ToString();
            object theModel;
            if (DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))
                result = result + theModel;
#endif

            environment.phone = result;

            Debug.Assert(ScreenSize.X * ScreenSize.Y > 0, "Screen size was not set.");

            environment.ScreenWidth = ScreenSize.X;
            environment.ScreenHeight = ScreenSize.Y;

            environment.gps_on = "unavailable";
#if WINDOWS_RT
            environment.ScreenDpi = DisplayProperties.LogicalDpi.ToString();
#else
            environment.ScreenDpi = "unavailable";
#endif
            environment.ScreenOrientation = ScreenOrientation;
            environment.wifi_on = NetworkInterface.GetIsNetworkAvailable() ? bool.TrueString : bool.FalseString;
            return environment;
        }
Exemplo n.º 5
0
        public void CacheEvent(AppEnvironment env, string tag, bool reserved = false)
        {
            var evtrequest = new BugSenseEventRequest(env, tag, reserved);
            string contents = evtrequest.getFlatLine();

            Task t = new Task(async () =>
                {
                    try
                    {
                        LogEvent evt = new LogEvent(contents, reserved);
                        _lockToSendEvt.WaitOne();
                        if (!evtrequest.TimeStamp.Equals(_prevEvtTs))
                        {
                            _prevEvtTs = evtrequest.TimeStamp;
                            _lockToSendEvt.Release();
                            Helpers.Log("begin(CacheEvent)");
                            string res = await evt.Execute();
                            Helpers.Log("end(CacheEvent): " + res);
                        }
                        else
                        {
                            Helpers.Log("Duplicate_Event(CacheEvent(" + _prevEvtTs + "))");
                            _lockToSendEvt.Release();
                        }
                    }
                    catch (Exception)
                    {
                        Helpers.Log("fail(CacheEvent)");
                    }
                });
            t.Start();
        }
Exemplo n.º 6
0
        public void SendEventNow(AppEnvironment env, string tag, bool reserved = false)
        {
            var evtrequest = new BugSenseEventRequest(env, tag, reserved);
            string contents = evtrequest.getFlatLine();

            Task t = new Task(async () =>
                {
                    try
                    {
                        string uuid = env.Uid;
                        string url = WebRequests.GetEventURL(uuid);
                        _lockToSendEvt.WaitOne();
                        if (!evtrequest.TimeStamp.Equals(_prevEvtTs))
                        {
                            _prevEvtTs = evtrequest.TimeStamp;
                            _lockToSendEvt.Release();
                            Helpers.Log("begin(SendEventNow-1)");
                            LogEvent evt = new LogEvent(contents, reserved);
                            string str = await evt.Execute();
                            if (!string.IsNullOrEmpty(str))
                            {
                                SendRequest msg = new SendRequest(url, str, false);
                                _lockToSend.WaitOne();
                                Helpers.Log("begin(SendEventNow-2)");
                                bool res = await msg.Execute();
                                Helpers.Log("end(SendEventNow-2): " + res);
                                _lockToSend.Release();
                            }
                            Helpers.Log("end(SendEventNow-1)");
                        }
                        else
                        {
                            Helpers.Log("Duplicate_Event(SendEventNow(" + _prevEvtTs + "))");
                            _lockToSendEvt.Release();
                        }
                    }
                    catch (Exception)
                    {
                        Helpers.Log("fail(SendEventNow)");
                    }
                });
            t.Start();
        }
Exemplo n.º 7
0
        public BugSenseExceptionRequest(BugSenseException ex, AppEnvironment environment, 
			Dictionary<string, string> extradata)
        {
            Client = new BugSenseClient();
            Request = new BugSenseInternalRequest();
            Request.Tag = string.IsNullOrEmpty(ex.Tag) ? null : ex.Tag;
            //TODO: Comment should ask user for feedback
            Request.Comment = "";
            Exception = ex;
            AppEnvironment = environment;
            LogData = extradata;
        }
Exemplo n.º 8
0
        public bool IsSimilarTo(AppEnvironment that)
        {
            bool res = false;

            res = Uid.Equals(that.Uid);
            res = res && PhoneModel.Equals(that.PhoneModel);
            res = res && PhoneManufacturer.Equals(that.PhoneManufacturer);
            res = res && AppVersion.Equals(that.AppVersion);
            res = res && AppName.Equals(that.AppName);
            res = res && OsVersion.Equals(that.OsVersion);
            res = res && Locale.Equals(that.Locale);
            res = res && GeoRegion.Equals(that.GeoRegion);
            res = res && CpuModel.Equals(that.CpuModel);
            res = res && (CpuBitness == that.CpuBitness);
            res = res && (IsTrial == that.IsTrial);

            return res;
        }
 public BugSenseRequest(BugSenseEx ex, AppEnvironment environment)
 {
     Client = new BugSenseClient();
     Request = new BugSenseInternalRequest();
     Request.Comment = string.IsNullOrEmpty(ex.Comment) ? ex.Name : ex.Comment;
     Exception = ex;
     AppEnvironment = environment;
 }
Exemplo n.º 10
0
        public static AppEnvironment GetEnvironment(string appName, string appVersion, string uuid,
            bool basic = false)
        {
            AppEnvironment environment = new AppEnvironment();

            environment.AppName = appName;
            environment.AppVersion = appVersion;

            environment.OsVersion = Environment.OSVersion.Version.ToString();

            environment.CpuModel = "unknown";
            environment.CpuBitness = sizeof(long) * 8;

            environment.IsTrial = Windows.ApplicationModel.Store.CurrentApp.LicenseInformation.IsTrial;

            string result = string.Empty;
            object manufacturer;
            if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))
                result = manufacturer.ToString();
            environment.PhoneManufacturer = result;

            object theModel;
            if (DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))
            {
                //NOTE: result contains model + manufacturer
                result = result + theModel;
            }
            //NOTE: currently, for model we don't include the manufacturer
            environment.PhoneModel = "" + theModel;

            environment.Locale = CultureInfo.CurrentCulture.EnglishName;

            environment.Uid = uuid;

            if (basic)
                return environment;

            try
            {
                environment.ScreenHeight = Application.Current.RootVisual.RenderSize.Height;
                environment.ScreenWidth = Application.Current.RootVisual.RenderSize.Width;
            }
            catch (Exception)
            {
                // If the exception is not in the UIThread we don't have access to above
            }

            string gps_on = "Unknown";
            if (GeoPositionPermission.Denied.Equals(true))
                gps_on = "Denied";
            else if (GeoPositionPermission.Granted.Equals(true))
            {
                if (GeoPositionStatus.Disabled.Equals(true))
                    gps_on = "Disabled";
                else if (GeoPositionStatus.Initializing.Equals(true))
                    gps_on = "Initializing";
                else if (GeoPositionStatus.NoData.Equals(true))
                    gps_on = "NoData";
                else if (GeoPositionStatus.Ready.Equals(true))
                    gps_on = "Ready";
            }
            environment.GpsOn = gps_on;

            string screen_orientantion = "unknown";
            try
            {
                if ((((PhoneApplicationFrame)Application.Current.RootVisual).Orientation & PageOrientation.Landscape) == PageOrientation.Landscape)
                    screen_orientantion = "Landscape";
                if ((((PhoneApplicationFrame)Application.Current.RootVisual).Orientation & PageOrientation.LandscapeLeft) == PageOrientation.LandscapeLeft)
                    screen_orientantion = "LandscapeLeft";
                if ((((PhoneApplicationFrame)Application.Current.RootVisual).Orientation & PageOrientation.LandscapeRight) == PageOrientation.LandscapeRight)
                    screen_orientantion = "LandscapeRight";
                if ((((PhoneApplicationFrame)Application.Current.RootVisual).Orientation & PageOrientation.Portrait) == PageOrientation.Portrait)
                    screen_orientantion = "Portrait";
                if ((((PhoneApplicationFrame)Application.Current.RootVisual).Orientation & PageOrientation.PortraitUp) == PageOrientation.PortraitUp)
                    screen_orientantion = "PortraitUp";
                if ((((PhoneApplicationFrame)Application.Current.RootVisual).Orientation & PageOrientation.PortraitDown) == PageOrientation.PortraitDown)
                    screen_orientantion = "PortraitDown";
            }
            catch (Exception)
            {
            }
            environment.ScreenOrientation = screen_orientantion;
            environment.ScreenDpi = "unavailable";

            environment.WifiOn =
                DeviceNetworkInformation.IsWiFiEnabled.Equals(true) ? 1 : 0;
            environment.CellularData =
                DeviceNetworkInformation.IsCellularDataEnabled.Equals(true) ? "true" : "false";
            environment.Carrier =
                DeviceNetworkInformation.CellularMobileOperator;

            environment.Rooted = false;

            return environment;
        }
        private AppEnvironment GetEnvironment()
        {
            AppEnvironment environment = new AppEnvironment();
            environment.AppName = _appName;
            environment.AppVersion = _appVersion;
            environment.OsVersion = Environment.OSVersion.Version.ToString();
            string result = string.Empty;
            object manufacturer;
            if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))
                result = manufacturer.ToString();
            object theModel;
            if (DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))
                result = result + theModel;

            environment.PhoneModel = result;
            try {
                environment.ScreenHeight = _application.RootVisual.RenderSize.Height;
                environment.ScreenWidth = _application.RootVisual.RenderSize.Width;
            }
            catch { /* If the exception is not in the UIThread we don't have access to above */ }

            environment.GpsOn = "unavailable";
            environment.ScreenDpi = "unavailable";
            environment.ScreenOrientation = "unavailable";
            environment.WifiOn = NetworkInterface.NetworkInterfaceType.ToString();
            return environment;
        }
        private AppEnvironment GetEnvironment()
        {
            AppEnvironment environment = new AppEnvironment();
            environment.appname = _appName;
            environment.appver = _appVersion;
            environment.osver = Environment.OSVersion.Version.ToString();
            string result = string.Empty;
            object manufacturer;
            //TODO: Find model
            if (DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out manufacturer))
                result = manufacturer.ToString();
            object theModel;
            if (DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))
                result = result + theModel;

            environment.phone = result;
            try {
                environment.ScreenHeight = _application.Window.ClientBounds.Height;
                environment.ScreenWidth = _application.Window.ClientBounds.Width;
            }
            catch { /* If the exception is not in the UIThread we don't have access to above */ }

            environment.gps_on = "unavailable";
            environment.ScreenDpi = "unavailable";
            environment.ScreenOrientation = _application.Window.CurrentOrientation.ToString();
            environment.wifi_on = NetworkInterface.GetIsNetworkAvailable().ToString(CultureInfo.InvariantCulture);
            return environment;
        }