protected override void OnStart(string[] args)
        {
            _accountService.Authorization();

            if (_configuration.IsAuthorized)
            {
                _debugLogService.SendDebugLog("", "SSPService starting...");

                _searchSuitableProfiles.Run();
            }
        }
        public void Run()
        {
            while (true)
            {
                var activeAccountsIds = _accountService.GetActiveAccountsIds()?.Ids;
                foreach (var activeAccountId in activeAccountsIds)
                {
                    var companiesForSearch = _companyService.GetCompaniesForSearch(activeAccountId, _configuration.SearchProfilesBatchSize);
                    if (companiesForSearch.CompanyProfilesViewModel != null && companiesForSearch.CompanyProfilesViewModel.Any())
                    {
                        SearchSuitableProfilesCompanies(activeAccountId, companiesForSearch.CompanyProfilesViewModel);
                        if (!_configuration.IsAuthorized)
                        {
                            break;
                        }
                    }
                }

                var timeOut = new TimeSpan(0, 30, 0);
                _debugLogService.SendDebugLog($"The next launch in { timeOut.TotalMinutes } minutes", "Pause");
                Thread.Sleep(timeOut);
            }
        }
        protected override void OnStart(string[] args)
        {
            _accountService.Authorization();

            if (_configuration.IsAuthorized)
            {
                _debugLogService.SendDebugLog("", "Scheduler service are starting...");

                var advanceSettingsResponse = _settingService.GetAdvanceSettings();
                var intervalType            = advanceSettingsResponse.AdvanceSettingsViewModel.IntervalType;
                var timeStart     = advanceSettingsResponse.AdvanceSettingsViewModel.TimeStart;
                var intervalValue = advanceSettingsResponse.AdvanceSettingsViewModel.IntervalValue;

                switch (intervalType)
                {
                case IntervalType.Hour:
                    _debugLogService.SendDebugLog("With an interval in Hours", "Start a schedule");
                    MyScheduler.IntervalInHours(timeStart.Hours, timeStart.Minutes, intervalValue,
                                                () =>
                    {
                        RunScraper();
                    });
                    break;

                case IntervalType.Day:
                    _debugLogService.SendDebugLog("With an interval in Days", "Start a schedule");
                    MyScheduler.IntervalInDays(timeStart.Hours, timeStart.Minutes, intervalValue,
                                               () =>
                    {
                        RunScraper();
                    });
                    break;

                default:
                    _debugLogService.SendDebugLog("Invalid IntervalType.Please, check the value of < INTERVAL_TYPE > in App.config.", "Error INTERVAL_TYPE");
                    break;
                }
            }
        }
        public bool Initialize()
        {
            try
            {
                if (!_configuration.IsAuthorized)
                {
                    _accountService.Authorization();

                    if (!_configuration.IsAuthorized)
                    {
                        return(false);
                    }
                }

                var advanceSettingsResponse = _settingService.GetAdvanceSettings();
                var settingsResponse        = _settingService.GetSettings();

                if (advanceSettingsResponse.StatusCode != (int)HttpStatusCode.OK ||
                    settingsResponse.StatusCode != (int)HttpStatusCode.OK)
                {
                    return(false);
                }

                _advanceSettingsVM = advanceSettingsResponse.AdvanceSettingsViewModel;
                _settingsVM        = settingsResponse.SettingsViewModel;
                debugLogVMs        = new List <DebugLogViewModel>();

                var options = new ChromeOptions();
                options.AddArgument("no-sandbox");
                _driver = new ChromeDriver(options);
                js      = (IJavaScriptExecutor)_driver;

                _driver.Manage().Window.Maximize();
                _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3);
                _driver.Navigate().GoToUrl("https://www.linkedin.com");


                return(true);
            }
            catch (Exception ex)
            {
                if (_configuration.IsAuthorized)
                {
                    _settingService.UpdateScraperStatus(ScraperStatus.Exception);
                    _debugLogService.SendDebugLog(ex.ToString(), "Error initialize scraper");
                }
                return(false);
            }
        }