コード例 #1
0
        public Device GetDevice()
        {
            Device d = new Device();
            //d.DeviceID;
            d.Brand = DeviceStatus.DeviceManufacturer;// String.Concat(DeviceExtendedProperties.GetValue("DeviceManufacturer"));
            d.Description = null;
            d.Detail = GetDetails();
            d.DevUUID = GetDeviceUUID();
            d.Model = DeviceStatus.DeviceName;// String.Concat(DeviceExtendedProperties.GetValue("DeviceName"));
            d.OSDescription = null;
            d.Owner = null; //no way
            d.Platform = "WindowsPhone";
            d.PushID = "";
            d.Resolution = GetScreenResolution();
            d.Version = String.Format("{0}.{1}.{2}", System.Environment.OSVersion.Version.Major, System.Environment.OSVersion.Version.Minor, System.Environment.OSVersion.Version.Revision);

            return d;
        }
コード例 #2
0
        private void Register(Device dev)
        {
            dev.App = _appName;
            dev.Owner = _owner;
            dev.AppVersion = ApplicationInfo.Version;
            if (_deviceID == null || _deviceID == 0 || _resend)
            {
                dev = SendDeviceToServer(dev);
                if(dev != null)
                {
                    _deviceID = dev.DeviceID;
                    RLSettings.DeviceID = _deviceID;
                }
            }

            if (_self._deviceID == 0)
            {
                // only if request to server was sucesfull, but respond doesn't have
                // an ID
                _self._connector = null;
                throw new InvalidOperationException("Unable to register device!");
            }

            _logSender = new LogSender(_connector);

            //push
            if (_pushNotifications)
            {
                try
                {
                    OnRegisterPushNotifications(String.IsNullOrEmpty(dev.PushID));
                }
                catch (Exception e)
                {
                    RLog.E(this, e);
                }
            }

            //settings
            try
            {
                Respond<Settings[]> settings = LoadSetttingsBlocking();
                OnLoadSettings(settings);
                if (SettingsLoaded != null)
                {
                    SettingsLoaded.Invoke(this, settings);
                }
            }
            catch (Exception e)
            {
                //ignore error for load settings
                RLog.E(this, e);
            }

            //unhandled exception in main thread
            string stack = RLSettings.UnhandledExceptionStack;
            if (!String.IsNullOrEmpty(stack))
            {
                LogItem li = CreateLogItem();
                li.Message = "Unhandled exception history";
                LogItemBlobRequest libr = new LogItemBlobRequest(LogItemBlobRequest.MIME_TEXT_PLAIN, "fatalerror.txt", stack);
                libr.IsUnhandledException = true;
                RLog.Send(typeof(Application), "UnhandledException", "History stack trace", libr);
            }

            if (RegistrationFinished != null)
            {
                RegistrationFinished.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="device"></param>
 /// <returns></returns>
 private Device SendDeviceToServer(Device device)
 {
     Device result = null;
     try
     {
         Respond<Device> dr = _connector.SaveDevice(device);
         if (dr == null || dr.HasError)
         {
             Debug.WriteLine(dr.Message);
         }
         else
         {
             result = dr.Context;
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.StackTrace);
     }
     return result;
 }
コード例 #4
0
 /// <summary>
 /// Send device to server
 /// </summary>
 /// <param name="d"></param>
 /// <returns>Updated device, including DeviceID</returns>
 public Respond<Device> SaveDevice(Device d)
 {
     string toSend = JsonConvert.SerializeObject(d);
     string json = SendRequest(toSend, URL + REGS_URL, HTTP_POST);
     Respond<Device> res = JsonConvert.DeserializeObject<Respond<Device>>(json, RemoteLog.Settings);
     return res;
 }