Esempio n. 1
0
        private static void RecordToURL(NewDeviceData newDevice)
        {
            HttpWebRequest request = WebRequest.Create(_newDevicesUrl) as HttpWebRequest;

            request.Timeout = Constants.NewUrlTimeOut;
            request.Method  = "POST";

            StreamWriter writer = new StreamWriter(request.GetRequestStream());

            writer.Write(newDevice.Content);
            writer.Flush();
            writer.Close();

            request.GetResponse();
        }
Esempio n. 2
0
        private static void ProcessNewDevice(object sender)
        {
            NewDeviceData newDevice = sender as NewDeviceData;

            if (newDevice != null)
            {
                try
                {
                    // Record to a URL if one has been provided and the new devices.
                    if (String.IsNullOrEmpty(Manager.NewDevicesURL) == false &&
                        String.IsNullOrEmpty(newDevice.Content) == false)
                    {
                        RecordToURL(newDevice);
                    }
                }
                catch (SecurityException)
                {
                    EventLog.Warn(String.Format("Insufficient permission to send new device information to '{0}'.",
                                                _newDevicesUrl));
                    _enabled = false;
                }
                catch (WebException ex)
                {
                    try
                    {
                        if (newDevice.IsLocal == false)
                        {
                            EventLog.Warn(
                                String.Format(
                                    "Could not write device information for useragent '{0}' to URL '{1}'. Exception '{2}'",
                                    newDevice.UserAgent, _newDevicesUrl, ex.Message));
                        }
                        else
                        {
                            EventLog.Debug(
                                String.Format(
                                    "Could not write device information for useragent '{0}' to URL '{1}'. Exception '{2}'",
                                    newDevice.UserAgent, _newDevicesUrl, ex.Message));
                        }
                    }
                    catch
                    {
                        // Do nothing as there is nothing we can do.
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Record the client in the new devices server if specified to avoid
        /// needing to use this method to match the useragent to the device
        /// in the future. Create another thread with low priority to reduce
        /// any impacting of recording this on the active web request.
        /// </summary>
        /// <param name="request">The request used to indentify the new device.</param>
        internal static void RecordNewDevice(HttpRequest request)
        {
            // Get the new device details.
            NewDeviceData data = new NewDeviceData(request);

#if VER4
            if (!data.Ignore)
            {
                Task.Factory.StartNew(() => ProcessNewDevice(data));
            }
#elif VER2
            if (data.Ignore == false)
            {
                ThreadPool.QueueUserWorkItem(ProcessNewDevice, data);
            }
#endif
        }
Esempio n. 4
0
 /// <summary>
 /// Record the client in the new devices server if specified to avoid
 /// needing to use this method to match the useragent to the device
 /// in the future. Create another thread with low priority to reduce
 /// any impacting of recording this on the active web request.
 /// </summary>
 /// <param name="request">The request used to indentify the new device.</param>
 internal static void RecordNewDevice(HttpRequest request)
 {
     // Get the new device details.
     NewDeviceData data = new NewDeviceData(request);
     #if VER4
     if (!data.Ignore)
         Task.Factory.StartNew(() => ProcessNewDevice(data));
     #elif VER2
     if (data.Ignore == false)
         ThreadPool.QueueUserWorkItem(ProcessNewDevice, data);
     #endif
 }
Esempio n. 5
0
        private static void RecordToURL(NewDeviceData newDevice)
        {
            HttpWebRequest request = WebRequest.Create(_newDevicesUrl) as HttpWebRequest;
            request.Timeout = Constants.NewUrlTimeOut;
            request.Method = "POST";

            StreamWriter writer = new StreamWriter(request.GetRequestStream());
            writer.Write(newDevice.Content);
            writer.Flush();
            writer.Close();

            request.GetResponse();
        }