public TaskForm(IStorageService <SedeAppDto> storageService) { InitializeComponent(); _ss = storageService; _tds = new TasksDataService(_ss); this._regions = this.GetRegions(); }
public Main(SeaSettings settings) { _settings = settings; InitializeComponent(); _lc = new LoggerConsole { MdiParent = this }; _logger = _lc; _storage = new JsonStorageService <SedeAppDto>(SeaVariables.JsonStorageDb); _tds = new TasksDataService(_storage); _recaptcha = new RuCaptchaResolver(SeaVariables.ReCaptchaApiKey, SeaVariables.SitaCaptchaUrl, _logger); _ps = new SedeProxyService(_logger); _ps.OnProxyCallback += UpdateActiveProxyesCount; _ps.LaunchCheckAdressesState(); f = new FileService(_logger); InitializeUiForms(); InitializeScripts(); var callback = new TimerCallback(LaunchTasksProccesing); var rand = new Random(); var randTime = rand.Next(this._settings.TaskProccesingMinDueTimeout * 1000, this._settings.TaskProccesingMaxTimeout * 1000); _processTasksTimer = new Timer(callback, null, randTime, randTime); var cb = new TimerCallback(LaunchConstitutionTasksProccesing); var cRand = new Random(); var cRandTime = cRand.Next(this._settings.ConstitutionTaskProcessingMinDueTimeout * 1000, this._settings.ConstitutionTaskProcessingMaxTimeout * 1000); _processConstitutuionTasksTimer = new Timer(cb, null, cRandTime, cRandTime); }
public void LaunchTasksProccesing(object obj) { var tls = new TasksDataService(_storage); var data = tls.GetInProgressTasks(); _logger.Info($"Initialize tasks processing -> available {data.Length} task(s)..."); foreach (var u in data) { var a = _ps.GetAvailibleAdress(); if (a != null) { switch (u.ProcedureRegion) { case "Illes Balears": _controller = new IllesBalearsController(u, a, _logger, _recaptcha, this._settings); break; case "Madrid": _controller = new MadridController(u, a, _logger, _recaptcha, this._settings); break; case "Alicante": _controller = new AlicanteController(u, a, _logger, _recaptcha, this._settings); break; case "Barcelona": _controller = new BarcelonaController(u, a, _logger, _recaptcha, this._settings); break; case "Murcia": _controller = new MurciaController(u, a, _logger, _recaptcha, this._settings); break; case "Girona": _controller = new GironaController(u, a, _logger, _recaptcha, this._settings); break; default: _controller = null; break; } if (!ReferenceEquals(_controller, null)) { _logger.Info("Controller has been initialized -> Launch task..."); _controller.OnStepsControllerMailCallback += ControllerMailerCallback; _controller.OnStepsControllerCitaStatusCallback += CitaStatusCallback; _controller.SolveStepsAsync(); } } else { _logger.Warning( "Sorry, but we cant't launch chrome now, we need more proxy servers to correct work, try again later"); } } var rand = new Random(); var randTime = rand.Next(this._settings.TaskProccesingMinDueTimeout * 1000, this._settings.TaskProccesingMaxTimeout * 1000); _processTasksTimer.Change(randTime, randTime); }