Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int ieversion = GetInternetExplorerMajorVersion();
                Response.Write("ieversion=" + ieversion + "<br />");

                BrowserEmulationVersion browserEmulationVersion = GetBrowserEmulationVersion();
                Response.Write("browserEmulationVersion=" + browserEmulationVersion.ToString() + "<br />");

                //if (!IsBrowserEmulationSet())
                //{
                //    SetBrowserEmulationVersion();
                //}

                if (HttpContext.Current.Request.Cookies["bwjsCookie20180106"] != null)
                {
                    Utils.DelCoookie("bwjsCookie20180106");
                }
                else
                {
                    Utils.WriteCookie("bwjsCookie20180106", "token", "1000", 2);
                    Utils.WriteCookie("bwjsCookie20180106", "consultId", "b938b7e4-d50e-49b7-af98-08a090322189", 2);
                }

                string consultId = Utils.GetCookie("bwjsCookie20180106", "token");
                string token     = Utils.GetCookie("bwjsCookie20180106", "consultId");
            }
        }
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            bool result;

            result = false;
            try
            {
                RegistryKey key;
                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);
                if (key != null)
                {
                    string programName;
                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }
                    result = true;
                }
            }

            catch (UnauthorizedAccessException)
            {
                // The user does not have the necessary registry rights.
            }
            return(result);
        }
            public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
            {
                bool result;

                result = false;


                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = System.IO.Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }


                return(result);
            }
Exemple #4
0
        private static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                        logger.Warn("SETTING REGISTRY:{0}-{1}-{2}-{3}", key.Name, programName, (int)browserEmulationVersion, RegistryValueKind.DWord.ToString());
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                        logger.Warn("DELETING REGISTRY KEY:{0}-{1}", key.Name, programName);
                    }

                    result = true;
                }
            }
            catch (SecurityException se)
            {
                // The user does not have the permissions required to read from the registry key.
                logger.Error(se);
            }
            catch (UnauthorizedAccessException uae)
            {
                // The user does not have the necessary registry rights.
                logger.Error(uae);
            }

            return(result);
        }
Exemple #5
0
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion, Form1 form)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                        form.Logni("IE pro Ticketník nastaveno na verzi " + (int)browserEmulationVersion, Form1.LogMessage.INFO);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (SecurityException)
            {
                form.Logni("Selhal zápis registrů pro IE verzi", Form1.LogMessage.WARNING);
            }
            catch (UnauthorizedAccessException)
            {
                form.Logni("Chybí práva zápisu registrů pro IE verzi", Form1.LogMessage.WARNING);
            }

            return(result);
        }
Exemple #6
0
        /// <summary>
        /// Sets the browser emulation version for the application.
        /// </summary>
        /// <param name="browserEmulationVersion">The browser emulation version.</param>
        /// <returns><c>true</c> the browser emulation version was updated, <c>false</c> otherwise.</returns>
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (SecurityException e)
            {
                LogMessage.Error("You do not have the permissions required to write to the registry key. Please try by restarting application as Administarator.\r\n" + Log.GetExceptionMessage(e));
            }
            catch (UnauthorizedAccessException e)
            {
                LogMessage.Error("You do not have the necessary registry rights. Please try by restarting application as Administarator.\r\n" + Log.GetExceptionMessage(e));
            }

            return(result);
        }
        public static void SetBrowserIEVersion()
        {
            int version = InternetExplorerBrowserEmulation.GetInternetExplorerMajorVersion();

            BrowserEmulationVersion browserEmulationVersion = BrowserEmulationVersion.Default;

            switch (version)
            {
            case 11:
                browserEmulationVersion = BrowserEmulationVersion.Version11Edge;
                break;

            case 10:
                browserEmulationVersion = BrowserEmulationVersion.Version10Standards;
                break;

            case 9:
                browserEmulationVersion = BrowserEmulationVersion.Version10;
                break;
            }
            InternetExplorerBrowserEmulation.SetBrowserEmulationVersion(browserEmulationVersion);
        }
        /// <summary>
        /// Sets the browser emulation version for the application.
        /// </summary>
        /// <param name="browserEmulationVersion">The browser emulation version.</param>
        /// <param name="programName">The name of the program to add a Registry Key for.</param>
        /// <returns><c>true</c> the browser emulation version was updated, <c>false</c> otherwise.</returns>
        internal static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion, string programName)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (SecurityException)
            {
                // The user does not have the permissions required to read from the registry key.
            }
            catch (UnauthorizedAccessException)
            {
                // The user does not have the necessary registry rights.
            }

            return(result);
        }
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (Exception)
            {
                ActivityLog.LogWarning(ExtensionName, "Failed to set the registry key for FEATURE_BROWSER_EMULATION");
            }

            return(result);
        }
Exemple #10
0
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (Exception ex)
            {
                Kohl.Framework.Logging.Log.Error("Unable to set browser emulation mode", ex);
            }

            return(result);
        }
Exemple #11
0
        private void UseLatestIE()
        {
            int ieValue = this.GetInternetExplorerMajorVersion();
            BrowserEmulationVersion result = BrowserEmulationVersion.Default;

            switch (ieValue)
            {
            case 11:
                result = BrowserEmulationVersion.Version11;
                break;

            case 10:
                result = BrowserEmulationVersion.Version10;
                break;

            case 9:
                result = BrowserEmulationVersion.Version9;
                break;

            case 8:
                result = BrowserEmulationVersion.Version8;
                break;

            default:
                result = BrowserEmulationVersion.Version7;
                break;
            }

            if (ieValue != 0)
            {
                using (RegistryKey registryKey =
                           Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true))
                {
                    registryKey?.SetValue(Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName), (int)result,
                                          RegistryValueKind.DWord);
                }
            }
        }
        private static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            return(UseRegistryKey(Microsoft.Win32.Registry.CurrentUser, BrowserEmulationKey, true, key =>
            {
                if (key != null)
                {
                    var programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, Microsoft.Win32.RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    return true;
                }
                return false;
            }));
        }
Exemple #13
0
        /// <summary>
        /// Set the browser's IE version in registry
        /// </summary>
        /// <param name="browserEmulationVersion"></param>
        /// <returns></returns>
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            try
            {
                var result = false;
                var key    = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);
                if (key != null)
                {
                    var programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }

                return(result);
            }
            catch (SecurityException ex)
            {
                Logger("The user does not have the permissions required to read from the registry key: " + ex.ToString());
                return(false);
            }
            catch (UnauthorizedAccessException ex)
            {
                Logger("The user does not have the necessary registry rights: " + ex.ToString());
                return(false);
            }
        }
Exemple #14
0
	   public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
		{
		  bool result;
		
		  result = false;
		
		  try
		  {
		    RegistryKey key;
		
		    key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);
		
		    if (key != null)
		    {
		      string programName;
		
		      programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
		
		      if (browserEmulationVersion != BrowserEmulationVersion.Default)
		      {
		        // if it's a valid value, update or create the value
		        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
		      }
		      else
		      {
		        // otherwise, remove the existing value
		        key.DeleteValue(programName, false);
		      }
		
		      result = true;
		    }
		  }
		  catch (Exception ex)
		  {
		  	Kohl.Framework.Logging.Log.Error("Unable to set browser emulation mode", ex);
		  }
		
		  return result;
		}
        /// <summary>
        /// Sets the browser emulation version for the application.
        /// </summary>
        /// <param name="browserEmulationVersion">The browser emulation version.</param>
        /// <returns><c>true</c> the browser emulation version was updated, <c>false</c> otherwise.</returns>
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            bool result;

            result = false;

            try
            {
                RegistryKey key;

                key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);

                if (key != null)
                {
                    string programName;

                    programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (SecurityException e)
            {
                LogMessage.Error("You do not have the permissions required to write to the registry key. Please try by restarting application as Administarator.\r\n" + Log.GetExceptionMessage(e));
            }
            catch (UnauthorizedAccessException e)
            {
                LogMessage.Error("You do not have the necessary registry rights. Please try by restarting application as Administarator.\r\n" + Log.GetExceptionMessage(e));
            }

            return result;
        }
 public BrowserEmulator(BrowserEmulationVersion version11)
 {
     SetBrowserEmulationVersion(BrowserEmulationVersion.Version11);
 }
Exemple #17
0
        /// <summary>
        /// Set the browser's IE version in registry
        /// </summary>
        /// <param name="browserEmulationVersion"></param>
        /// <returns></returns>
        public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
        {
            var result = false;
            try
            {
                var key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);
                if (key != null)
                {
                    var programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
                    if (browserEmulationVersion != BrowserEmulationVersion.Default)
                    {
                        // if it's a valid value, update or create the value
                        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
                    }
                    else
                    {
                        // otherwise, remove the existing value
                        key.DeleteValue(programName, false);
                    }

                    result = true;
                }
            }
            catch (SecurityException)
            {
                // The user does not have the permissions required to read from the registry key.
            }
            catch (UnauthorizedAccessException)
            {
                // The user does not have the necessary registry rights.
            }
            return result;
        }