Exemplo n.º 1
0
        private void AddSourceTask(ICaptchaHarvesterTask harvesterTask = null, bool isAuto = true)
        {
            RecaptchaParameter taskParameter = harvesterTask?.Parameter as RecaptchaParameter;

            RecaptchaParameter parameter = new RecaptchaParameter()
            {
                SiteKey  = taskParameter?.SiteKey ?? SiteKey,
                SitePath = taskParameter?.SitePath ?? SitePath
            };

            ICaptchaSolutionSourceTask sourceTask = null;

            if (isAuto)
            {
                sourceTask = GetSolutionSource()?.GetSolution(parameter);
            }
            else
            {
                sourceTask = m_manualSource.GetSolution(parameter);
            }

            if (sourceTask != null)
            {
                sourceTask.SolutionReleased += SolutionReleaseEventHanlder;

                m_sourceTasks[sourceTask] = taskParameter != null ? harvesterTask : null;
            }
        }
Exemplo n.º 2
0
        private void CreateApiTask(AntiCaptchaTask task, RecaptchaParameter parameter)
        {
            task.Id = null;

            Task <string> apiTask = AntiCaptchaApi.CreateReCaptchaTask(ApiKey, parameter.SiteKey, parameter.SitePath, CancelToken);

            lock (m_lock)
            {
                m_tasks[task] = apiTask;
            }
        }
Exemplo n.º 3
0
        public ICaptchaSolutionSourceTask GetSolution(object parameter)
        {
            TwoCaptchaTask     res = new TwoCaptchaTask();
            RecaptchaParameter p   = parameter as RecaptchaParameter;

            res.Parameter = p;

            CreateApiTask(res, p);

            m_checkTasksTimer.Change(m_checkPeriod, Timeout.Infinite);

            return(res);
        }
Exemplo n.º 4
0
        public ICaptchaSolutionSourceTask GetSolution(object parameter)
        {
            AntiCaptchaTask    res = new AntiCaptchaTask();
            RecaptchaParameter p   = parameter as RecaptchaParameter;

            res.Parameter = p;

            CreateApiTask(res, p);

            lock (m_lock)
            {
                if (!m_isCheckTimerLaunched)
                {
                    m_isCheckTimerLaunched = true;
                    m_checkTasksTimer.Change(m_checkPeriod, Timeout.Infinite);
                }
            }

            return(res);
        }