Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Permission()
 {
     SystemConfiguration = new SystemConfiguration.SystemConfiguration();
     DataSetup = new DataSetup.DataSetup();
     TenantSetup = new TenantSetup.TenantSetup();
     UserSetup = new UserSetup.UserSetup();
     RoleSetup = new RoleSetup.RoleSetup();
     Reports = new Reports.Reports();
     Dashboards = new Dashboards.Dashboards();
     Access = new Access.Access();
     Scheduling = new Scheduling.Scheduling();
     Emailing = new Emailing.Emailing();
     Exporting = new Exporting.Exporting();
     Systemwide = new Systemwide.Systemwide();
 }
Exemplo n.º 2
0
        public async Task InitSelenium(Account acc, bool newAccess = true)
        {
            this.acc = acc;
            Access.Access access = newAccess ? acc.Access.GetNewAccess() : acc.Access.GetCurrentAccess();

            SetupChromeDriver(access, acc.AccInfo.Nickname, acc.AccInfo.ServerUrl);

            if (this.Html == null)
            {
                this.Html = new HtmlAgilityPack.HtmlDocument();
            }

            InitHttpClient(access);
            if (!string.IsNullOrEmpty(access.Proxy))
            {
                var checkproxy = new CheckProxy();
                await checkproxy.Execute(acc);
            }
            else
            {
                await this.Navigate($"{acc.AccInfo.ServerUrl}/dorf1.php");
            }
        }
Exemplo n.º 3
0
        private void SetupChromeDriver(Access.Access access, string username, string server)
        {
            ChromeOptions options = new ChromeOptions();

            // Turn on logging preferences for buildings localization (string).
            //var loggingPreferences = new OpenQA.Selenium.Chromium.ChromiumPerformanceLoggingPreferences();
            //loggingPreferences.IsCollectingNetworkEvents = true;
            //options.PerformanceLoggingPreferences = loggingPreferences;
            //options.SetLoggingPreference("performance", LogLevel.All);

            if (!string.IsNullOrEmpty(access.Proxy))
            {
                // add WebRTC Leak
                var extensionPath = DisableWebRTCLeak.CreateExtension(username, server, access);
                options.AddExtension(extensionPath);

                if (!string.IsNullOrEmpty(access.ProxyUsername))
                {
                    // Add proxy authentication
                    extensionPath = ProxyAuthentication.CreateExtension(username, server, access);
                    options.AddExtension(extensionPath);
                }

                options.AddArgument($"--proxy-server={access.Proxy}:{access.ProxyPort}");
                options.AddArgument("ignore-certificate-errors"); // --ignore-certificate-errors ?
            }

            options.AddArgument($"--user-agent={access.UserAgent}");

            //options.AddArguments("--disable-logging");
            //options.AddArguments("--disable-metrics");
            //options.AddArguments("--disable-dev-tools");
            //options.AddArguments("--disable-gpu-shader-disk-cache");
            //options.AddArguments("--aggressive-cache-discard");
            //options.AddArguments("--arc-disable-gms-core-cache");

            // Mute audio because of the Ads
            options.AddArguments("--mute-audio");

            // Make browser headless to preserve memory resources
            // if (acc.Settings.HeadlessMode) options.AddArguments("headless");

            // Do not download images in order to preserve memory resources / proxy traffic
            if (acc.Settings.DisableImages)
            {
                options.AddArguments("--blink-settings=imagesEnabled=false");                             //--disable-images
            }
            // Add browser caching
            var dir = IoHelperCore.GetCacheDir(username, server, access);

            Directory.CreateDirectory(dir);
            options.AddArguments("user-data-dir=" + dir);

            // Hide command prompt
            chromeService = ChromeDriverService.CreateDefaultService();
            chromeService.HideCommandPromptWindow = true;

            try
            {
                if (acc.Settings.OpenMinimized)
                {
                    options.AddArguments("--window-position=5000,5000");
                    this.Driver = new ChromeDriver(chromeService, options);
                    this.Driver.Manage().Window.Position = new System.Drawing.Point(200, 200); // TODO: change coords?
                    this.Driver.Manage().Window.Minimize();
                }
                else
                {
                    this.Driver = new ChromeDriver(chromeService, options);
                }

                // Set timeout
                this.Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(60);
            }
            catch (Exception e)
            {
                acc.Logger.Error(e, $"Error opening chrome driver! Is it already opened?");
            }
        }
Exemplo n.º 4
0
 private void InitHttpClient(Access.Access a)
 {
     RestClient = new RestClient();
     HttpHelper.InitRestClient(a, RestClient);
 }